Commit Graph

891 Commits

Author SHA1 Message Date
Danny Mösch f5ea2492dc Merge allowed symbols with alphanumerics where possible 2023-06-18 12:01:28 +02:00
Danny Mösch b89e43a799 Make sure case check can be disabled by new off option value (#5064) 2023-06-17 22:27:57 +02:00
JP Simard 7462187191 Add 5.9 to Swift version tests (#5057)
This gets all tests passing with Xcode 15 beta 1.
2023-06-12 18:39:18 +00:00
woxtu c735e6320f Add Swift version 5.8.1 (#5050) 2023-06-05 16:52:35 +00:00
Danny Mösch a2ba0a0626 Omit "Rule" in configuration names (#5024) 2023-05-20 04:39:04 -04:00
Danny Mösch 3f039f26d5 Connect configs with their referencing rules to have some context in error logging (#5017)
With the binding of configurations to their associated rule types
"unknown configuration" errors can be made more specific mentioning
also the rule's identifier in the printed message.
2023-05-19 20:58:24 +02:00
Danny Mösch d938b2d3c3 Specify default options in configurations only (#5020) 2023-05-18 17:21:30 +02:00
Danny Mösch 405113f793 Open ConfigurationError up to be used more broadly (#5005) 2023-05-14 20:00:46 +02:00
Danny Mösch 0ffe0c5911 Extract tests for NameConfiguration 2023-05-10 22:20:30 +02:00
Danny Mösch c99a4286b8 Let validates_start_with_lowercase option in name configurations expect a severity 2023-05-10 22:20:30 +02:00
Andyy Hope 5e15039554 Move excludedPaths out of iteration loop to speed up lint times (#4955) 2023-05-06 16:43:33 -04:00
Simon Støvring 9054ec0658 Add test verifying that the file_header rule can require an empty file header (#4928) 2023-05-01 18:47:37 +02:00
JP Simard a7bc9e20c7 Move built-in rules to new SwiftLintBuiltInRules module (#4950) 2023-04-27 11:16:01 -04:00
JP Simard 86d60400c1 Move core SwiftLint functionality to new SwiftLintCore module
Over the years, SwiftLintFramework had become a fairly massive monolith,
containing over 400 source files with both core infrastructure and
rules.

Architecturally, the rules should rely on the core infrastructure but
not the other way around. There are two exceptions to this:
`custom_rules` and `superfluous_disable_command` which need special
integration with the linter infrastructure.

Now the time has come to formalize this architecture and one way to do
that is to move the core SwiftLint functionality out of
SwiftLintFramework and into a new SwiftLintCore module that the rules
can depend on.

Beyond enforcing architectural patterns, this also has the advantage of
speeding up incremental compilation by skipping rebuilding the core
functionality when iterating on rules.

Because the core functionality is always useful when building rules, I'm
opting to import SwiftLintCore in SwiftLintFramework as `@_exported` so
that it's implicitly available to all files in SwiftLintFramework
without needing to import it directly.

In a follow-up I'll also split the built-in rules and the extra rules
into their own modules. More modularization is possible from there, but
not planned.

The bulk of this PR just moves files from `Source/SwiftLintFramework/*`
to `Source/SwiftLintCore/*`. There are some other changes that can't be
split up into their own PRs:

* Change jazzy to document the SwiftLintCore module instead of
  SwiftLintFramework.
* Change imports in unit tests to reflect where code was moved to.
* Update `sourcery` make rule to reflect where code was moved to.
* Create a new `coreRules` array and register those rules with the
  registry. This allows the `custom_rules` and
  `superfluous_disable_command` rule implementations to remain internal
  to the SwiftLintCore module, preventing more implementation details
  from leaking across architectural layers.
* Move `RuleRegistry.registerAllRulesOnce()` out of the type declaration
  and up one level so it can access rules defined downstream from
  SwiftLintCore.
2023-04-26 21:10:19 -04:00
JP Simard 4c04cdafa7 Introduce SwiftLintTestCase
To consistently set up rules before tests
2023-04-25 12:28:50 -04:00
JP Simard 165172e0fa Introduce a "rule registry" concept
This will allow for registering rules that aren't compiled as part of
SwiftLintFramework.

Specifically this will allow us to split the built-in and extra rules
into separate modules, leading to faster incremental compilation when
working on rules since the rest of the framework won't need to be
rebuilt on every compilation.
2023-04-25 12:28:50 -04:00
Sven Münnich a2facce70c Fix false positives related to multiline strings in indentation_width rule (#4862) 2023-04-04 19:27:16 +02:00
Danny Mösch ee849bcb10 Remove unused imports (#4856) 2023-04-03 19:26:59 +02:00
Danny Mösch 16e2bb0f18 Extend xct_specific_matcher rule to check for boolean asserts on (un)equal comparisons (#3858) 2023-04-02 12:30:21 +02:00
Danny Mösch 82491e6f84 Add Swift version 5.8 (#4851) 2023-03-31 22:44:25 +02:00
Danny Mösch 3d15419adb Fix warnings in Swift 5.8/Xcode 14.3 (#4850) 2023-03-31 22:13:20 +02:00
Martin Redington 7dad240ea7 Add a reporters subcommand (#4836) 2023-03-31 08:09:01 +02:00
Martin Redington ca43d2359b Fix unit test configuration (#4847) 2023-03-30 22:46:31 +02:00
Martin Redington 5a91b1e392 Fixed display of optin and correctable (#4841)
Co-authored-by: Martin Redington <mildm8nnered@gmail.com>
2023-03-27 07:48:51 +02:00
JP Simard efc5afd5d5 Apply small formatting fixes (#4840)
* Trim excess trailing and vertical whitespace
* Move `SwiftyTextTable` dependency into `frameworkDependencies`
* Adjust wording in README around analyzer rules in the `opt_in_rules`
  section, since analyzer rules can only go in the `analyzer_rules`
  section.
2023-03-26 16:09:43 -04:00
Martin Redington f2d15355be Add a summary table reporter (#4820) 2023-03-25 08:28:42 +01:00
Danny Mösch 06578e5d91 Get rid of some more disabled commands 2023-03-12 00:03:02 +01:00
Danny Mösch 1bf2f25e40 Get rid of some disabled commands (#4807) 2023-03-11 08:20:47 -05:00
Martin Redington 31510b662e Use all optin rules facility for SwiftLint's own .swiftlint.yml (#4800) 2023-03-11 11:59:05 +01:00
Martin Redington 0bd8a7aba6 Add new blanket_disable_command rule (#4731) 2023-03-07 21:43:53 +01:00
Martin Redington 228d53787b Stopsuperfluous_disable_command from firing when disabled (#4791) 2023-03-05 19:21:35 +01:00
Martin Redington d73d87ac97 Add include_multiline_strings option to indentation_width rule (#4785) 2023-02-26 11:52:29 +01:00
Michael S 9c216baf20 Add new relative-path reporter (#4739) 2023-02-07 23:23:00 +01:00
Danny Mösch 5af4291b53 Let Emoji reporter print rule identifier (#4708) 2023-02-06 16:28:07 -05:00
Danny Mösch d3ebfc5567 Let number_separator rule trigger on misplaced separators (#4685) 2023-02-06 16:22:31 -05:00
Danny Mösch 5eed8fe91b Enable if_let_shadowing rule and fix all violations (#4247) 2023-01-31 22:31:38 +01:00
Patrick 651b00eb70 Updated JUnit reporter (#4725) 2023-01-30 20:48:29 +01:00
JP Simard c84124d8bc Enable all tests when using rules_xcodeproj (#4723)
* Revert "Skip tests requiring runfiles support when testing with rules_xcodeproj (#4694)"

This reverts commit 040096a641.

* Enable all tests when using rules_xcodeproj

Turns out we don't need runfiles support
(https://github.com/buildbuddy-io/rules_xcodeproj/issues/828) since the
tests run outside the sandbox in Xcode, so we can get the path to these
files from the `BUILD_WORKSPACE_DIRECTORY` environment variable that
`bazel test` sets.
2023-01-26 21:18:05 -05:00
Danny Mösch 341db66f3c Support Swift version 5.7.3 (#4711) 2023-01-19 15:35:41 -05:00
JP Simard 040096a641 Skip tests requiring runfiles support when testing with rules_xcodeproj (#4694)
rules_xcodeproj doesn't support runfiles yet:
https://github.com/buildbuddy-io/rules_xcodeproj/issues/828
2023-01-16 13:09:56 -05:00
kyounh12 5ec6112ba1 Interpret strings in excluded option of *_name rules as regex (#4655) 2023-01-10 23:29:04 +01:00
Danny Mösch e64e82d80d Get rid of periods finishing rule descriptions 2023-01-10 22:29:13 +01:00
Danny Mösch 67eb330f1c Add key to severity configuration as a hint for the correct YAML syntax 2023-01-08 15:05:43 +01:00
Danny Mösch d6ff2a7f37 Rewrite explicit_type_interface rule with SwiftSyntax fixing a false-positive (#4638) 2023-01-01 23:23:50 +01:00
Danny Mösch 64d9619a8a Report violations in all <scope>_length rules when error < warning threshold (#4647) 2023-01-01 23:15:36 +01:00
Danny Mösch 83ee9a89dd Add Swift version 5.7.2 (#4648) 2022-12-17 04:18:21 -05:00
Danny Mösch 93d0d8fa7f Fix configuration parsing error in unused_declaration rule (#4619) 2022-12-05 23:11:19 +01:00
Ryan Aveo 92304cdd98 Fix building tests in Xcode (#4607)
Co-authored-by: JP Simard <jp@jpsim.com>
2022-11-30 10:33:33 -05:00
JP Simard 4ccf9eebb4 Fix line count calculation for multiline string literals (#4587)
Fixes https://github.com/realm/SwiftLint/issues/4585

Update body length rule thresholds for SwiftLint
2022-11-24 16:40:51 +00:00
JP Simard ac21584224 Fix minimum_fraction_length handling in number_separator (#4583)
Fixes https://github.com/realm/SwiftLint/issues/4576

Before it would apply the `minimum_length` parameter to the
`minimal_fractional_length` setting if the latter wasn't set.
2022-11-24 14:19:20 +00:00