Commit Graph

32 Commits

Author SHA1 Message Date
Danny Mösch 4065fc8437 Enable upcoming feature MemberImportVisibility (#6286) 2025-10-08 08:12:05 +02:00
Danny Mösch 530bf9d0c5 Let legacy function rules adhere to @SwiftSyntaxRule (#6271) 2025-10-03 08:03:59 -04:00
Danny Mösch b58b8401a0 Improve detection of comment-only lines in file_length rule (#6231) 2025-09-04 10:27:26 +02:00
Danny Mösch b97f63a89d Properly detect comment-only lines (#6230) 2025-09-03 23:42:04 +02:00
Danny Mösch 4efdcc7b25 Base visitors on rule configuration (#6159) 2025-07-10 18:13:06 -04:00
Danny Mösch 599e51a5a2 Format code (#6151) 2025-07-02 17:50:53 -04:00
Danny Mösch 5a3c8c9ba3 Inline rule-specific parts of BodyLengthVisitor (#6121)
Main goal is to bring implementations, rules and examples closer together.
Another advantage is that the rule's layouts are in line with other
`@SwiftSyntaxRule`s.

After the refactoring, violation messages can be
better adapted to the object causing the issue. Violation positions
should be harmonized and more cases for protocols, subscripts and
deinitializers can be added.
2025-06-21 14:02:28 +02:00
Danny Mösch 22e0f42ae1 Fix crash when disable command is preceded by unicode character (#5976) 2025-03-15 23:33:11 +01:00
Danny Mösch cbedb0844e Inline custom visitors (#5909) 2024-12-23 15:18:35 +01:00
Danny Mösch 15e1598d43 Move reusable functionality from SwiftLintBuiltInRules to SwiftLintCore 2024-12-23 12:51:43 +01:00
Danny Mösch 88191fe58e Enable prefer_key_path rule and fix all violations (#5721) 2024-08-03 14:21:47 +02:00
Danny Mösch 238415b4f7 Place corrections optionally into violations (#5680)
This avoids maintaining two lists of objects.
2024-07-20 16:24:17 +02:00
Danny Mösch cc4b569c54 Enable unused_parameter rule and fix all violations (#5673) 2024-07-14 11:20:50 -04:00
Danny Mösch e48bdb7adf Add new unused_parameter rule (#5668) 2024-07-14 05:31:29 -04:00
Danny Mösch c810459e6a Enforce mandatory trailing comma and fix all violations (#5640) 2024-06-28 05:36:50 +00:00
Danny Mösch 5bfe329d09 Update SwiftSyntax to version 510.0.0 (#5479) 2024-03-09 15:46:45 -05:00
Danny Mösch 1603f4ab55 Remove filter that is assuming classes cannot be nested inside of extensions (#5344) 2023-11-11 14:28:16 +01:00
Danny Mösch 779f6f0910 Add missing subscript declaration 2023-11-11 14:06:06 +01:00
Danny Mösch 3a03e7a31f Extract method that checks if a declaration shall be skipped 2023-11-11 14:06:06 +01:00
Danny Mösch 40bd97038a Support arbitrary configurations in @SwiftSyntaxRule (#5275)
Almost all rules based on SwiftSyntax can be set up now by just adding
`@SwiftSyntaxRule` to the rule struct.
2023-10-16 19:34:43 +02: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 35a78815d1 Update SwiftSyntax (#5198) 2023-09-14 22:49:55 +02:00
Tatsuyuki Kobayashi b609a4bebb Fix false positive in test_case_accessibility (#5212) 2023-09-08 10:12:55 -07:00
Martin Redington a459ccf5c4 Drop support for disable/enable commands in multiline comments (#4803) 2023-09-03 18:09:55 -04:00
Danny Mösch be83b486ca Generalize alternative way to rewrite code (#5163) 2023-08-31 17:00:07 -04:00
Danny Mösch b281a8d33a Update SwiftSyntax (#5168) 2023-08-30 22:57:10 +02:00
Kasra Babaei 6e2bd8c059 Skip initializers in private_subject rule (#5096) 2023-07-04 21:45:17 +02:00
Danny Mösch a68e062ac3 Extract methods (#5085) 2023-06-26 16:37:34 -04:00
Danny Mösch 83ab977a1b Introduce visitor that tracks declared variables while traversing the AST 2023-06-13 23:24:48 +02:00
JP Simard e5cf99088b Update SwiftSyntax to 509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-06-05-a (#5058)
Diff: https://github.com/apple/swift-syntax/compare/509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-05-02-a...509.0.0-swift-DEVELOPMENT-SNAPSHOT-2023-06-05-a
2023-06-12 15:22:17 -04:00
Danny Mösch 704c9ae116 Move ViolationsSyntaxVisitor into its own file (#5028) 2023-05-22 07:35:46 -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