Commit Graph

7105 Commits

Author SHA1 Message Date
Danny Mösch a41c49aff4 Kepp build running with a single job 2025-08-08 10:50:53 +02:00
Danny Mösch 42da5e55c2 Add debug log output 2025-08-08 10:08:08 +02:00
Danny Mösch 07572f1dd7 Add Bazel debug build on Linux 2025-08-07 22:11:59 +02:00
Copilot 8cda6c66e9 Fix no_extension_access_modifier rule triggering on nonisolated modifier (#6174)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-08-04 13:12:37 -04:00
Danny Mösch a809480d4a Let Copilot prefer Bazel (#6173)
* Add instructions for rule registration
* Add setup steps for coding agent using Bazel
* Make callable workflow so that its environment also applies to subsequent steps
2025-08-04 18:16:59 +02:00
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 7395ead738 Add basic Copilot instructions 2025-08-01 17:39:49 +02:00
Danny Mösch 5738a6138e Revert "Add setup steps for coding agent"
This reverts commit deb3678e6f.
2025-08-01 16:31:39 +02:00
Danny Mösch deb3678e6f Add setup steps for coding agent 2025-08-01 16:22:16 +02:00
Danny Mösch 00f2d21652 Add config schema 2025-08-01 16:10:13 +02: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
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 532e6617ed Disable background indexing in Swift extension
https://github.com/swiftlang/sourcekit-lsp/issues/2205
2025-07-14 21:21:11 +02: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 8229f45de4 Update dependencies (#6162) 2025-07-11 23:40:08 +02: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 4efdcc7b25 Base visitors on rule configuration (#6159) 2025-07-10 18:13:06 -04:00
Danny Mösch 571e6c1818 Run remaining Azure build jobs on GitHub Actions (#6149) 2025-07-09 22:43:50 +02:00
Danny Mösch df96466163 Support deinitializers and subscripts in function body length checking (#6142) 2025-07-09 16:33:49 -04:00
Danny Mösch 6af2aed49d Ensure that closure_end_indentation doesn't drop comments (#6158) 2025-07-09 15:54:59 -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
Rodion Ivashkov 097bef27ef Fix configuration handling in multiline_parameters for stricter validation (#6148) 2025-07-02 17:04:45 -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 de613ba8b7 Prepare rule for SwiftSyntax 6.2 (#6144) 2025-06-29 12:40:11 -04:00
Danny Mösch 929f0fc5c2 Add warmup step to OSS check (#6134) 2025-06-27 10:29:30 +02:00
Danny Mösch 546f71bb2d Add additional newline to first token in file (#6141)
For all first tokens in a line the newline character causing the new
line is part of the leading trivia. The only exception is the very first
token in a file because at the beginning of a file, there is no previous
line that needs to be broken.
2025-06-27 10:28:24 +02:00
Danny Mösch d4fbe69e7b Report remaining fixed and new violations (#6140) 2025-06-26 21:23:26 +02:00
Danny Mösch 24437220be Use path pattern to exclude generated tests in config (#6138) 2025-06-25 21:43:42 +02:00
Danny Mösch 17c77cd1f8 Print workspace directory only in debug builds (#6137) 2025-06-25 19:39:45 +00: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 f7f3caa50e Migrate TrailingWhitespaceRule from SourceKit to SwiftSyntax (#6117)
## Summary

Convert TrailingWhitespaceRule to use SwiftSyntax instead of SourceKit
for improved performance and better handling of trailing whitespace
detection, especially within block comments.

## Key Technical Improvements

- **Enhanced block comment detection** distinguishing between lines fully
  covered by block comments vs lines containing block comments with code
- **Accurate whitespace detection** using CharacterSet.whitespaces for
  all Unicode whitespace characters, not just space and tab
- **Improved comment handling** with proper detection of line-ending
  comments and multi-line block comment structures
- **Better correction mechanism** using ViolationCorrection ranges
  instead of manual string reconstruction
- **Line-based analysis** maintaining efficiency while providing precise
  violation positions

## Migration Details

- Replaced `CorrectableRule` with `@SwiftSyntaxRule(correctable: true)`
- Implemented `ViolationsSyntaxVisitor` pattern for line-based validation
- Added `collectLinesFullyCoveredByBlockComments` to properly handle
  test framework comment wrapping scenarios
- Distinguished between three comment scenarios: lines fully within block
  comments, full-line comments, and lines ending with comments
- Maintained all configuration options (ignores_empty_lines, ignores_comments)
- Preserved exact violation position reporting with UTF-8 offset calculations
2025-06-24 21:12:32 -04: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
Danny Mösch d14e22a57f Migrate Linux builds from Azure to GitHub Actions (#6132)
This allows for better reusability and integration. macOS builds still run on Azure due to GitHub's limitation of up to 5 macOS jobs running concurrently.
2025-06-24 10:07:17 +02:00
Danny Mösch 4b9208a37b Ignore various assignment operators in void_function_in_ternary (#6133) 2025-06-24 09:47:40 +02:00
JP Simard 388d45246e Migrate ExpiringTodoRule from SourceKit to SwiftSyntax (#6113) 2025-06-23 07:43:04 -04:00
Danny Mösch ac476aaf13 Run Swift linting job with Bazel for better caching (#6130) 2025-06-22 20:24:37 +02: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
Kent Kaseda c22de52b9b Respect ignore_swiftui_view_bodies option in view builders and preview macros/providers (#6075)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-06-22 01:32:48 +02: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
JP Simard 4ecae5b252 Migrate LineLengthRule from SourceKit to SwiftSyntax (#6111)
Convert LineLengthRule to use SwiftSyntax instead of SourceKit for
improved performance and better detection accuracy.

The SwiftSyntax implementation:
- Uses ViolationsSyntaxVisitor pattern with line-based validation
- Pre-computes ignored lines using helper visitors for efficiency
- Implements pure SwiftSyntax comment detection without SourceKit
- Correctly handles function declarations, multiline strings
- Maintains all configuration options including URL stripping
- Preserves exact line position reporting for violations
2025-06-21 14:47:19 -04:00
Danny Mösch 6650ebdd87 Put contributors on a new line 2025-06-21 20:45:13 +02:00
JP Simard 45c4766a02 Migrate AccessibilityLabelForImageRule from SourceKit to SwiftSyntax (#6101)
* Migrate AccessibilityLabelForImageRule from SourceKit to SwiftSyntax

\## Summary

Fix `.accessibilityElement(children:)` exemption logic where the
previous implementation incorrectly exempted images with `.combine`
when only `.ignore` should exempt children.

\## Improvements Based on OSSCheck Results

\### New Violations (Legitimately Detected)
- `Image(uiImage:)` and `Image(nsImage:)` calls providing contextual
  content
- Previously missed by SourceKit's pattern matching limitations
- These represent real accessibility issues requiring labels

\### Fixed Violations (False Positives Removed)
- Images inside Button/NavigationLink labels (containers handle
  accessibility)
- Images in custom components with proper accessibility context
- System icons incorrectly flagged when already accessible

\## Key Technical Improvements

- **Comprehensive detection** of all Image initializer types
- **Better context awareness** through syntax tree traversal
- **Accurate `.accessibilityElement(children:)` behavior**
  (`.ignore` exempts, `.combine`/`.contain` do not)
- **Reduced false positives** while catching real accessibility issues

\## Regression Test Examples

Added comprehensive examples demonstrating the migration benefits:

\### Non-Triggering (Reduced False Positives)
- Images in `Button`/`NavigationLink` labels with accessibility context
- Images in containers with `.accessibilityElement(children: .ignore)`
- Complex hierarchies where container accessibility handles children
- Various Image initializer types in proper accessible contexts

\### Triggering (Improved Detection)
- `Image(uiImage:)` and `Image(nsImage:)` providing contextual content
- Images in containers with `.combine`/`.contain` that don't exempt
- Status icons, favicons, and background images needing labels

* Update changelog
2025-06-21 11:34:06 -04:00
Danny Mösch 286e67ff23 Report more specific target types (#6123) 2025-06-21 17:17:55 +02:00
Danny Mösch 18403e8604 Harmonize violation positions (#6124) 2025-06-21 17:15:25 +02:00