Commit Graph

133 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 c1ffdfe891 Enable prefer_condition_list rule (#6163) 2025-07-12 09:41:00 -04:00
Danny Mösch 599e51a5a2 Format code (#6151) 2025-07-02 17:50:53 -04:00
Danny Mösch de613ba8b7 Prepare rule for SwiftSyntax 6.2 (#6144) 2025-06-29 12:40:11 -04:00
JP Simard 388d45246e Migrate ExpiringTodoRule from SourceKit to SwiftSyntax (#6113) 2025-06-23 07:43:04 -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 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
JP Simard 5eac9be50d Migrate AccessibilityTraitForButtonRule from SourceKit to SwiftSyntax (#6108)
## Summary

Convert AccessibilityTraitForButtonRule to use SwiftSyntax instead of
SourceKit for improved performance and better accessibility trait
detection in SwiftUI modifier chains.

## Key Technical Improvements

- **Bidirectional modifier chain analysis** for comprehensive
  accessibility trait detection
- **Better context awareness** through SwiftSyntax tree traversal
- **Accurate container exemption logic** for Button/Link components
- **Enhanced gesture detection** supporting `.onTapGesture` and
  `.gesture` modifiers
- **Improved performance** with SwiftSyntax visitor pattern over
  SourceKit AST parsing

## Migration Details

- Replaced `ASTRule` with `@SwiftSyntaxRule(optIn: true)` annotation
- Implemented `ViolationsSyntaxVisitor` pattern for systematic tree
  traversal
- Added bidirectional accessibility trait detection that checks both
  before and after tap gestures
- Enhanced exemption logic for inherently accessible containers
  (Button, NavigationLink)
- Maintained full compatibility with existing rule behavior and test
  cases
2025-06-21 10:11:43 -04:00
JP Simard 81474e36d0 Enforce SourceKitFreeRule contract with fatal error (#6107) 2025-06-20 07:25:01 -04:00
Sonal e2ef7ed470 Treat actors as classes in class_delegate_protocol rule (#6067)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2025-06-15 17:56:09 +00: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
Danny Mösch 2578cb3862 Use SwiftSyntax version 601.0.0 (#6003) 2025-04-03 21:27:57 +02:00
Jared Grubb 63fea48d83 Add excluded_methods option to unneeded_override rule (#6010) 2025-03-22 21:40:05 +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 6ba231a11a Consider composed inherited types (#5984) 2025-01-30 22:50:18 +01:00
Riley Williams 651776896e Remove lints for redundant_sendable on protocols (#5959) 2025-01-13 23:15:40 +00:00
Danny Mösch 3f2b86c54d Remove trailing comma when Sendable was last (#5955) 2025-01-13 20:18:54 +01:00
Danny Mösch 1d8af83b48 Collect corrections together with violations (#5916) 2024-12-27 09:58:53 +01:00
Danny Mösch ff21ff796c Specify rule properties in attribute 2024-12-26 20:40:29 +01:00
Danny Mösch 03f8c83d0d Add new redundant_sendable rule (#5902) 2024-12-25 23:05:02 +01:00
Martin Redington deaacf6f69 Fixed PrivateUnitTestRule deprecations (#5912) 2024-12-25 19:43:27 +00: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 f2175c1906 Remove deprecated inert_defer rule entirely (#5894) 2024-12-09 18:30:22 -05:00
Danny Mösch 40f9a2a18e Remove deprecated rule entirely (#5889)
The rule has been deprecated for 2 years.
2024-12-07 09:25:29 -05:00
Danny Mösch 7dd8e65d4f Ignore super calls with trailing closures (#5887) 2024-12-05 16:38:34 -05:00
jkolarik-paylocity 0ce122e716 Add new async_without_await rule (#5869)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2024-11-27 16:15:25 -05:00
Martin Redington 01f5ecd64a Replace description.identifier with identifier (#5837) 2024-10-26 14:46:03 +01:00
Paul Taykalo 832821259a Make use of transitive imports configuration (#5622)
Co-authored-by: Danny Mösch <danny.moesch@icloud.com>
2024-10-25 19:43:49 +02:00
Danny Mösch d4b41bc53b Stop triggering on self in key path expressions (#5836) 2024-10-24 16:50:18 +00:00
Danny Mösch 1767dab485 Add Swift 6 presentation of map(_:) type (#5804) 2024-09-21 11:53:30 +00:00
Danny Mösch 37f15d4388 Suggest broader initializer accepting Sequences (#5794) 2024-09-16 18:16:35 +00:00
Danny Mösch 85c4dbe963 Ensure expected initializer signature (#5786) 2024-09-09 21:18:00 +00:00
Sam Rayner 48aaca61f0 Reverse Data -> String conversion rule (#5601) 2024-08-24 10:13:04 +00:00
Martin Redington 60a1d342f4 Remove anyobject_protocol rule (#5770) 2024-08-24 10:51:04 +02:00
Danny Mösch f3bdd27626 Silence unneeded_override rule on methods and initializers with attributes (#5764) 2024-08-21 18:56:51 +02:00
Danny Mösch cffb331009 Fix spurious Bazel build errors (#5756) 2024-08-18 20:53:57 +00:00
Danny Mösch 78b665d536 Unroll parsing code to make Version a struct (#5730) 2024-08-05 21:48:50 +00:00
Danny Mösch 88191fe58e Enable prefer_key_path rule and fix all violations (#5721) 2024-08-03 14:21:47 +02:00
Martin Redington 103e585b56 Make sure that violations of the typesafe_array_init rule are correctly reported as violations of that rule rather than array_init (#5710) 2024-07-28 19:05:03 +01:00
LamTrinh.Dev 03b28d5ece Fix typo (#5691) 2024-07-24 18:31:29 +00:00
Danny Mösch 9f8a3f5662 Fix some typos (#5683) 2024-07-20 11:22:32 -04: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
Martin Redington 3421f5f46d Enable multiline_parameters rule, and fix all cases (#5664) 2024-07-18 01:48:02 +01:00
Danny Mösch 2442e10f13 Avoid needless indentation in examples (#5675) 2024-07-16 13:57:05 -04: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 67b1aaa211 Trigger missing_docs rule on declaration-introducing keyword (#5671) 2024-07-14 05:38:16 -04:00
Danny Mösch e48bdb7adf Add new unused_parameter rule (#5668) 2024-07-14 05:31:29 -04:00