Commit Graph

215 Commits

Author SHA1 Message Date
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
Danny Mösch ba500d31a2 Remove unused code (#6208)
All the code has a relation to former SourceKit-based rules.
2025-08-30 14:09:07 +02:00
Erik Kerber 69c9e29833 Add Sendable conformance to Rule.Type for building with Swift 6 (#6169) 2025-07-30 09:36:11 +02:00
Danny Mösch c1ffdfe891 Enable prefer_condition_list rule (#6163) 2025-07-12 09:41:00 -04:00
Danny Mösch 092d0c3b62 Keep severity levels unchanged when no options are configured (#6160) 2025-07-11 04:18:28 -04:00
Danny Mösch 4efdcc7b25 Base visitors on rule configuration (#6159) 2025-07-10 18:13:06 -04:00
Chris Brakebill c97cf24797 Add ignore_codingkeys parameter in nesting rule (#5650)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-07-09 15:09:38 -04:00
Danny Mösch 599e51a5a2 Format code (#6151) 2025-07-02 17:50:53 -04:00
JP Simard f6c9633087 Add RegexConfiguration.ExecutionMode (#6128)
* Add `RegexConfiguration.ExecutionMode`

To help migrate custom rules to SwiftSyntax. Not wired up yet, just the
configuration parsing and defaults. Will wire it up in the next PR.

The diff looks big, but it's 500+ lines of tests, with ~45 lines of
actually new code.

* Docs

* Address PR feedback

- Add `default` case to ExecutionMode enum instead of using optional
- Change configuration key from `mode` to `execution_mode` for consistency
- Move default execution mode logic to runtime instead of configuration time
- Refactor test functions to use throws instead of do-catch
2025-06-22 10:19:14 -04:00
JP Simard 3a922d41f9 Add ConditionallySourceKitFree to migrate custom rules to SwiftSyntax (#6127)
The protocol will be used to tag rules that may or may not require
SourceKit depending on its configuration. I only expect this to be used
for custom rules as utility to help transition to a fully SwiftSyntax
based approach.
2025-06-21 15:54:56 -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
JP Simard 5a2cf4b1fe Remove dead code (#6125)
In particular lots of stuff that used to be needed with SourceKit that
we no longer need to keep around.

Identified using Periphery: https://github.com/peripheryapp/periphery
2025-06-21 15:19:37 -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
JP Simard 81474e36d0 Enforce SourceKitFreeRule contract with fatal error (#6107) 2025-06-20 07:25:01 -04:00
Danny Mösch 614c0026df Prepare for Swift 6.2 (#6115) 2025-06-20 09:25:59 +00:00
Danny Mösch 125dd161cf Support latest Swift versions 2025-06-15 19:08:16 +02:00
Martin Redington f72f195ece Fix error reporting (#6061) 2025-05-21 11:34:46 +01:00
Martin Redington 3ed7579fd2 Allow magic numbers to be configured (#6051) 2025-04-13 21:08:42 +01:00
Danny Mösch e3c0eebe86 Document missing parameters 2025-04-09 21:11:41 +02:00
Danny Mösch 47335d7f95 Remove tracking of correction positions (#5950)
Report number of corrections per file instead.
2025-04-05 06:04:37 -04:00
Danny Mösch 2578cb3862 Use SwiftSyntax version 601.0.0 (#6003) 2025-04-03 21:27:57 +02:00
Danny Mösch 904538487c Support Swift version 6.1 (#6040) 2025-03-31 23:25:25 +02:00
Danny Mösch 043f9cac5b Introduce internal CLI to simplify development tasks (#6032)
Start with a command that generates a template for a new SwiftSyntax
rule. This tool could remain separate or be merged into the official
binary under a `dev` sub-command at a later point in time.
2025-03-23 01:21:41 +01:00
Danny Mösch b14272d4f2 Rewrite type_contents_order rule with SwiftSyntax (#6002) 2025-03-17 20:15:02 +01:00
Danny Mösch 22e0f42ae1 Fix crash when disable command is preceded by unicode character (#5976) 2025-03-15 23:33:11 +01:00
Martin Redington 5517d233fd Started to add rationales (#5681) 2025-03-06 10:16:30 +00:00
Danny Mösch 82736d1925 Add new opaque_over_existential rule (#5915) 2025-02-12 16:46:28 -05:00
Danny Mösch 82fd3e4058 Ensure that content is complete using an awaitable stream (#5986) 2025-02-10 22:59:43 +01:00
Keith Bauer 4eb19bef17 Parallelize file grouping (#5983) 2025-02-01 07:10:44 -05:00
Danny Mösch fcdc98a52d Revert "Improve performance of excluded files filter" (#5962)
This reverts commit 152355e36f from #5157.

# Conflicts:
#	tools/oss-check
2025-01-15 19:15:44 +01:00
Danny Mösch f045130e3e Remove unused protocol CollectingCorrectableRule (#5951) 2025-01-13 09:43:17 +01:00
Danny Mösch f796fee241 Enable strict concurrency checks in test code (#5943) 2025-01-07 22:19:25 +01:00
Danny Mösch a5c9319e13 Fix warnings in Linux build (#5940) 2025-01-06 18:28:20 +01:00
Danny Mösch bef8acfb0e Avoid NSRegularExpression in configurations (#5921) 2024-12-28 12:54:23 -05:00
Danny Mösch dd157e2bdf Use task-local variable (#5919) 2024-12-28 10:44:07 +01:00
Danny Mösch ff21ff796c Specify rule properties in attribute 2024-12-26 20:40:29 +01:00
Danny Mösch 152355e36f Improve performance of excluded files filter (#5157)
The current algorithm is like "collect all included files and subtract all excluded files".
Collecting all included and all excluded files relies on the file system. This can become slow
when the patterns used to exclude files resolve to a large number of files.

The new approach only collects all lintable files and checks them against the exclude patterns.
This can be done by in-memory string-regex-match and does therefore not require file system accesses.
2024-12-25 17:33:33 -05:00
Danny Mösch ec35f95786 Fix strict concurrency warnings in SwiftLintCore 2024-12-23 16:52:10 +01:00
Danny Mösch 1a54e3e313 Capture console on main actor only 2024-12-23 16:52:10 +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 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 23ba688c88 Combine compact and flat mapping (#5897) 2024-12-15 17:20:18 -05:00
Dinesh Sharma 8e3b50fa61 Add new category for @IBSegueAction to type_contents_order rule (#5524)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2024-12-14 18:02:54 -05:00
Danny Mösch 172d85ab7a Add pre-defined internal Swift 6 version (#5872) 2024-11-28 18:00:44 -05:00
Danny Mösch 25f2776977 Release 0.57.1 2024-11-24 16:06:56 +01:00
Danny Mösch 2c7e7230b0 Support type casting on configuration option values defined by environment variables (#5860) 2024-11-17 15:40:39 +01:00
Martin Redington 23d6a7c3f5 Added lenient command line option (#5801) 2024-10-30 22:03:54 +00:00