23 Commits

Author SHA1 Message Date
Danny Mösch d1cdf8ce20 Extend redundant_self_in_closure to find all redundant selfs (#6346) 2025-12-07 07:49:50 -05:00
Danny Mösch 2e87be0398 Infer name of parent rule in configurations (#6363) 2025-12-01 14:15:00 -05:00
Danny Mösch 9b3b538a18 Add @WorkingDirectory and @TemporaryDirectory macros to be used in tests 2025-10-03 22:41:38 +02:00
Danny Mösch 77050e8c40 Enable a fully statically linked Linux executable (#6211)
If SwiftLint is built from this state using the Swift SDK, we'll get a
large self-contained Linux executable that runs without loading SourceKit.
It can do that by disabling any rule that requires SourceKit.

With `SWIFTLINT_DISABLE_SOURCEKIT` set on a normally (dynamically linked)
binary, the behavior is the same. That's different from the previously
reported more serious warnings.
2025-08-30 10:02:38 -04:00
JP Simard d22e7335ab Add SwiftSyntaxKindBridge to help migrate custom rules to SwiftSyntax (#6126)
This provides an alternative to getting syntax kinds from SourceKit. The
mappings aren't 100% equivalent, but this should serve as a useful
compatibility layer.
2025-06-21 15:27:21 -04:00
Danny Mösch ff21ff796c Specify rule properties in attribute 2024-12-26 20:40:29 +01:00
Danny Mösch a6c4fd98bc Move files from SwiftLintCore to SwiftLintFramework
Ideally, SwiftLintCore would some day only contain components
that are needed to define rules. Consequently, it would be the
only bundle required to import for (external) rule development.
2024-12-23 12:51:43 +01:00
Danny Mösch ebdd23a4ad Support Musl C library (#5899) 2024-12-18 19:53:34 +01:00
Danny Mösch 010cbd8bc5 Reduce target-specific imports (#5898) 2024-12-18 16:12:52 +01:00
Danny Mösch 98cf87ab8d Rename macros to something more descriptive (#5686) 2024-07-23 20:14:29 +02:00
Danny Mösch e48bdb7adf Add new unused_parameter rule (#5668) 2024-07-14 05:31:29 -04:00
Koichiro Ueki aa9f474cb9 Add new no_empty_block rule (#5617) 2024-06-29 13:13:41 +02:00
Danny Mösch 5ec1de0312 Generate makeRewriter optionally (#5281) 2023-10-17 15:19:19 -04:00
Danny Mösch 58928b7e40 Enforce any on existential types (#5273)
This makes syntactically clear which types are rather expensive.
2023-10-12 08:37:23 +02:00
Danny Mösch f6e5f778fc Configure expression folding by argument of @SwiftSyntaxRule macro (#5255) 2023-10-03 07:16:33 -04:00
JP Simard 591154091e Introduce @SwiftSyntaxRule & @Fold macros (#5253)
These macros remove some of the boilerplate involved when writing rules.

This change also adds test infrastructure for the macros used within
SwiftLint.
2023-10-02 18:43:16 -04:00
Danny Mösch 2433e7b5bf Make use of macros to generate configuration parsing code (#5250) 2023-10-02 22:35:24 +02:00
Danny Mösch 5b64c1097a Fix runtime error when an excluded directory does not exist (#5143) 2023-07-25 21:25:04 +02:00
Danny Mösch 2c45e3c4c5 Fix method documentation (#5125) 2023-07-15 22:17:43 +00:00
Danny Mösch 83ab977a1b Introduce visitor that tracks declared variables while traversing the AST 2023-06-13 23:24:48 +02:00
Danny Mösch fe312a06fe Rely on pre-defined issues and allow to print them directly to the console (#5013)
Advantages of having typical errors at a common place:
* Error message styling can be harmonized
* Existing messages can be reused
* Overview of prefixes ('error: ', 'warning: ')
* Manage how to print them to the console
2023-05-16 20:15:14 +02:00
JP Simard 1e73835e83 Remove dead code (#5004)
Identified with the upcoming improved dead code detection.
2023-05-12 14:20:31 -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