Commit Graph
251 Commits
Author SHA1 Message Date
Danny Mösch 539bd28d86 Use URL for file paths throughout the code base 2025-12-28 08:46:16 +01:00
Roman LavrovandDanny Mösch 63f358c15b Restore Location.relativeFile to original implementation for now 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch 806cbfa71c fix comment length 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch 761000d42b TestResources.path() -> URL, resolve symlinks where tests fail on bazel 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch 42f0b0c407 back to join with / 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch 67973cb419 join / -> reduce append 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch 4160c3ad9b revert absolutePathStandardized change 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch e9a8f797a5 correct handling in PR 6355 for buildkite 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch 488f1c5164 fix lint 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch e998a83fae relativeFile strips prefix using pathComponents 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch ef8a46e544 relativeFile strips prefix instead of replacing occurrences 2025-12-23 15:08:35 +01:00
Roman LavrovandDanny Mösch 7d4b254d85 Add missing slash in removed path prefix 2025-12-23 15:08:35 +01:00
Saleem AbdulrasoolandDanny Mösch 4bfa266b09 various fixes for Windows path handling
An assortment of fixes that improve the test coverage on Windows. With
this set, local testing reveals 1 failure (RemoteCycleDetection) and
another set of test failures due to Windows globbing not matching the
POSIX semantics.
2025-12-23 15:08:35 +01:00
Brett BestandGitHub 5b1b83812a Support Swift version 6.2.3 (#6375) 2025-12-13 09:15:47 +00:00
Danny MöschandGitHub 66d4818cd3 Support Swift version 6.2.2 (#6373) 2025-12-10 21:10:39 +00:00
Danny MöschandGitHub ac701c088c Improve performance of excluded files filter (#6342)
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.
The new implementation also no longer traverses directories that already match an exclude pattern.

(cherry picked from commit 152355e36f)
2025-12-07 15:58:23 +01:00
Danny MöschandGitHub 32c33c2588 Re-enable redundant_self rule (#6368) 2025-12-07 08:11:08 -05:00
Danny MöschandGitHub d1cdf8ce20 Extend redundant_self_in_closure to find all redundant selfs (#6346) 2025-12-07 07:49:50 -05:00
562ec8f369 Correct incorrect handling of file paths (#6355)
`URL.path` is not a usable rendering of the path. `URL.path` represents
the URI path. If the path is meant to be consumable as a file path, the
file system representation (aka FSR) must be retrieved.

This improves the file path handling and makes additional tests now
pass.

Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-12-01 22:02:12 +01:00
Danny MöschandGitHub 2e87be0398 Infer name of parent rule in configurations (#6363) 2025-12-01 14:15:00 -05:00
Saleem AbdulrasoolandGitHub e526fdef94 Repair GenerationTests on Windows (#6354) 2025-11-28 09:04:17 +01:00
Danny MöschandGitHub f59f41b36e Support Swift version 6.2.1 (#6338) 2025-11-09 13:37:43 +01:00
Danny MöschandGitHub 9e5a526483 Enable unneeded_throws_rethrows rule (#6335) 2025-11-03 20:24:57 +01:00
038135e14d Enable prefer_key_path rule (#6331)
Co-authored-by: SimplyDanny <16365760+SimplyDanny@users.noreply.github.com>
2025-10-31 16:58:41 +00:00
Danny MöschandGitHub 7b4335abea Fix correction of sorted_imports rule for leading comments case (#6318) 2025-10-26 08:26:49 +01:00
Danny MöschandGitHub 4581152312 Introduce visitor collecting empty lines (#6320) 2025-10-25 07:36:48 -04:00
Nandhini SubramaniandGitHub 6619ca9c10 Add isolation parameter to modifier_order rule (#6316) 2025-10-22 09:40:45 +02:00
Danny MöschandGitHub 70a2e6ceac Add new incompatible_concurrency_annotation rule (#6290) 2025-10-20 15:11:10 -04:00
Nandhini SubramaniandGitHub 2c2ca671ed Add ignores_literals option to trailing_whitespace rule (#6309) 2025-10-18 04:31:52 -04:00
Danny MöschandGitHub 4065fc8437 Enable upcoming feature MemberImportVisibility (#6286) 2025-10-08 08:12:05 +02: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öschandGitHub 58be16cd0e Use task-local parser diagnostic toggle (#6273) 2025-10-03 22:34:32 +02:00
Danny MöschandGitHub 530bf9d0c5 Let legacy function rules adhere to @SwiftSyntaxRule (#6271) 2025-10-03 08:03:59 -04:00
Danny MöschandGitHub aa67f5ac13 Adopt typed throws where possible (#5922) 2025-09-27 19:11:46 +02:00
Danny MöschandGitHub b58b8401a0 Improve detection of comment-only lines in file_length rule (#6231) 2025-09-04 10:27:26 +02:00
Danny MöschandGitHub b97f63a89d Properly detect comment-only lines (#6230) 2025-09-03 23:42:04 +02:00
Danny MöschandGitHub 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öschandGitHub 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 KerberandGitHub 69c9e29833 Add Sendable conformance to Rule.Type for building with Swift 6 (#6169) 2025-07-30 09:36:11 +02:00
Danny MöschandGitHub c1ffdfe891 Enable prefer_condition_list rule (#6163) 2025-07-12 09:41:00 -04:00
Danny MöschandGitHub 092d0c3b62 Keep severity levels unchanged when no options are configured (#6160) 2025-07-11 04:18:28 -04:00
Danny MöschandGitHub 4efdcc7b25 Base visitors on rule configuration (#6159) 2025-07-10 18:13:06 -04:00
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öschandGitHub 599e51a5a2 Format code (#6151) 2025-07-02 17:50:53 -04:00
JP SimardandGitHub 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 SimardandGitHub 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 SimardandGitHub 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 SimardandGitHub 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öschandGitHub 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 SimardandGitHub 81474e36d0 Enforce SourceKitFreeRule contract with fatal error (#6107) 2025-06-20 07:25:01 -04:00