Commit Graph

1284 Commits

Author SHA1 Message Date
Copilot 8bb69b064a Add include_variables option to non_optional_string_data_conversion rule (#6172)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-08-02 17:49:58 -04:00
Danny Mösch aac32899c3 Exclude variable from concurrency analysis (#6170)
The variable is only used in `setUp` and `tearDown` and so access is not concurrent.
2025-07-30 12:57:35 +00:00
Danny Mösch c1ffdfe891 Enable prefer_condition_list rule (#6163) 2025-07-12 09:41:00 -04:00
Danny Mösch cb214d51fa Add new prefer_condition_list rule (#6157) 2025-07-12 07:52:50 -04:00
Danny Mösch a321566c05 Support protocols and extensions in type body length checking (#6143) 2025-07-11 22:27:47 +02: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 df96466163 Support deinitializers and subscripts in function body length checking (#6142) 2025-07-09 16:33:49 -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
Danny Mösch 14edabdee8 Enable unnecessarily disabled rule (#6150) 2025-07-01 21:41:48 +00:00
Danny Mösch fa61ea704c Fix test expectation (#6147) 2025-07-01 07:49:23 +00:00
Danny Mösch 24437220be Use path pattern to exclude generated tests in config (#6138) 2025-06-25 21:43:42 +02:00
Koichiro Ueki e65767baf8 Add new excluded_paths option to file_name rule (#6092)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-06-25 21:30:32 +02:00
JP Simard ab7d117030 Migrate FileHeaderRule from SourceKit to SwiftSyntax (#6112)
## Summary

Convert FileHeaderRule to use SwiftSyntax instead of SourceKit for
improved performance and better handling of file header comments,
shebangs, and doc comments.

## Key Technical Improvements

- **Enhanced shebang support** properly skipping past `#!/usr/bin/env swift` lines
- **Better comment type discrimination** excluding doc comments from header analysis
- **Accurate position calculation** converting between UTF-8 and UTF-16 offsets for regex matching
- **Improved trivia traversal** for comprehensive header comment collection
- **SwiftLint command filtering** to exclude directive comments from header content

## Migration Details

- Replaced `OptInRule` with `@SwiftSyntaxRule(optIn: true)` annotation
- Implemented `ViolationsSyntaxVisitor` pattern for file-level analysis
- Added logic to start header collection after shebang.endPosition if present
- Distinguished between regular comments and doc comments (///, /** */)
- Maintained UTF-16 offset calculations for NSRegularExpression compatibility
- Added `skipDisableCommandTests: true` for SwiftSyntax disable command behavior
- Removed unnecessary SourceKittenFramework import
2025-06-24 09:48:25 -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 18403e8604 Harmonize violation positions (#6124) 2025-06-21 17:15:25 +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
JP Simard 3c2f4e31c9 Shard GeneratedTests into parallel targets and refactor code generation (#6102)
Split the monolithic GeneratedTests target (242 test classes) into 10
sharded targets with ~25 tests each to enable parallel test execution.
Reduces test time from 85.4s to 36.7s (57% improvement) by running
shards concurrently. Most shards finish in 2-8s with 2 outliers at
30-37s.

The implementation automatically scales with new rules and provides
parallel test execution with improved code maintainability.
2025-06-19 22:20:17 +00:00
Matt Pennig 1e25cf6be6 Migrate VerticalWhitespaceRule from SourceKit to SwiftSyntax (#6103)
* Migrate VerticalWhitespaceRule from SourceKit to SwiftSyntax

* Adds tests for new horizontal whitespace behavior
2025-06-19 17:31:51 -04:00
Danny Mösch 125dd161cf Support latest Swift versions 2025-06-15 19:08:16 +02:00
Kent Kaseda e1ac6f8607 Remove validates_start_with_lowercase option entirely (#6077) 2025-05-15 16:48:00 -04:00
Martin Redington 3ed7579fd2 Allow magic numbers to be configured (#6051) 2025-04-13 21:08:42 +01:00
John Szumski 60b8f79d97 Allow FrameworkTests data to be empty (#6050)
Like so, a workspace can load the Tests package from a release archive.
2025-04-09 21:00:52 +02:00
Danny Mösch ed5b3741fe Remove opaque_over_existential rule (#6049)
This partially reverts commit 82736d1925.
2025-04-08 06:38:12 -04: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
Henry ed20aa593d Add new option ignores_multiline_strings to line_length rule (#6014) 2025-04-03 14:28:41 -04:00
Danny Mösch 904538487c Support Swift version 6.1 (#6040) 2025-03-31 23:25:25 +02:00
Danny Mösch 682fc1f708 Track correctable rules (#6037) 2025-03-26 22:35:45 +01:00
Danny Mösch 66dd38bb76 Register rules in test reference (#6036)
Integration test is so not needed anymore as complete registration
is already verified by a dedicated build job.
2025-03-26 21:05:04 +00:00
Danny Mösch 9710148f76 Replace Sourcery with internal implementation (#6034)
Tasks we perform with Sourcery are rather simple and can be replaced
with a basic collection of files and the generation of lists in the
new `swiftlint-dev` command. This spares contributors from installing
either Sourcery or Bazel.
2025-03-26 20:38:53 +00:00
fraioli e68797ebea Respect macro types in file_name rule (#6027)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-03-22 20:55:18 -04:00
Jared Grubb 63fea48d83 Add excluded_methods option to unneeded_override rule (#6010) 2025-03-22 21:40:05 +01:00
Danny Mösch 0004642abf Revert "Expose only SwiftLintCore in SPM and Bazel (#6021)"
This reverts commit 850eb7e214.
2025-03-16 19:23:39 +01:00
Danny Mösch 850eb7e214 Expose only SwiftLintCore in SPM and Bazel (#6021) 2025-03-16 16:44:44 +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
Eduard Miniakhmetov d2d1aacaac Add new allowed_types option to legacy_objc_type rule (#6012) 2025-03-10 09:28:04 +00:00
Danny Mösch a4db2f65c0 Skip integration tests in CI intentionally (#6017) 2025-03-09 20:26:39 +01: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
Danny Mösch 849dbfdd28 Enable upcoming features improving concurrency checking (#5994)
* `InferSendableFromCaptures`
* `GlobalActorIsolatedTypesUsability`
2025-02-10 19:23:42 +01:00
Danny Mösch a4893f60b2 Verify that severity can be configured per rule (#5985) 2025-01-31 20:01:51 +01:00
Keith Bauer 0460a6c1c6 Avoid reading files before checking the cache (#5973)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-01-29 15:53:13 -05:00
John Szumski 854d3f2e4c Fix issue referencing Tests package from another Bazel workspace (#5977)
Allow BuiltInRulesTests data to be empty so a workspace can load the Tests package from a release archive.
2025-01-22 18:43:31 +00: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 9b22cda361 Add ib_segue_action to default configuration (#5956) 2025-01-14 21:50:11 +01:00
Danny Mösch f045130e3e Remove unused protocol CollectingCorrectableRule (#5951) 2025-01-13 09:43:17 +01:00