Commit Graph

131 Commits

Author SHA1 Message Date
Martin Redington 33e3593c86 Skip simple tuples in no_magic_numbers rule (#5327) 2023-11-15 20:33:59 +01:00
Danny Mösch 9fbc04ecba Rewrite void_return rule with SwiftSyntax (#5351) 2023-11-15 07:13:36 +01:00
Danny Mösch 1603f4ab55 Remove filter that is assuming classes cannot be nested inside of extensions (#5344) 2023-11-11 14:28:16 +01:00
Kabir Oberai 92679e230d Fix implicit_getter false positive in case of unknown accessors (#5300) 2023-11-09 09:14:16 +01:00
Marcelo Fabri da597eaeca Add example for #3581 (#5334)
Fixes #3581
2023-11-07 09:26:15 +00:00
Marcelo Fabri 020a0e119a Rewrite vertical_parameter_alignment_on_call using SwiftSyntax (#5332) 2023-11-07 01:09:45 -08:00
Marcelo Fabri 5987582f93 Rewrite no_grouping_extension rule with SwiftSyntax (#5328) 2023-11-05 23:45:36 -08:00
JP Simard 6e3bfc1a45 Fix more strict concurrency warnings (#5324)
These aren't enough to enable `-strict-concurrency=complete` for more
modules, but they address some warnings with that flag on and reduces
the scope of what remains to be migrated.
2023-11-01 12:41:54 -04:00
JP Simard 3eb3772022 Compile with -strict-concurrency=complete (#5320)
* Compile with `-strict-concurrency=complete`

Only in Bazel for now, because this is considered an unsafe flag in
SwiftPM which would lead to warnings for downstream consumers of
SwiftLint using SwiftPM.

Some imports of SwiftSyntax need the `@preconcurrency` annotation until
https://github.com/apple/swift-syntax/pull/2322 is available in a
release.

The following SwiftLint libraries have `-strict-concurrency=complete`
applied:

* SwiftLintCoreMacros
* SwiftLintBuiltInRules
* SwiftLintExtraRules

The following SwiftLint libraries don't have the flag applied and need
to be migrated:

* SwiftLintCore
* swiftlint (CLI target)

So really the rules and macros are now being compiled with
`-strict-concurrency=complete`, but the core infrastructure of SwiftLint
is not.

Still, given that Swift 6 will eventually make these warnings errors by
default, it's good to prevent issues from creeping in earlier rather
than later.

* Add CI job to build with strict concurrency
2023-11-01 15:20:40 +00:00
uabyss 6dc4b86f98 Added viewIsAppearing in viewLifecycleMethodNames (#5316) 2023-11-01 08:48:49 -04:00
JP Simard 48604d35e3 Update Sourcery to 2.1.2 (#5318) 2023-10-31 20:34:49 +00:00
JP Simard c4ae9026cb Rewrite DuplicateImportsRule with SwiftSyntax (#5317) 2023-10-31 17:23:25 +00:00
JP Simard 0c635e447f Rewrite DiscouragedOptionalCollectionRule with SwiftSyntax (#5313) 2023-10-30 18:11:49 -04:00
Marcelo Fabri 686dc3dd32 Rewrite RedundantVoidReturnRule with SwiftSyntax (#4192)
Also include redundant void return clauses for closures in addition to
functions. This can be disabled by configuring the rule with
`include_closures: false`.

Co-authored-by: JP Simard <jp@jpsim.com>
2023-10-30 13:41:31 -04:00
Marcelo Fabri 715198ae3f Rewrite cyclomatic_complexity with SwiftSyntax (#5308) 2023-10-29 11:17:45 -07:00
Marcelo Fabri 5466f96818 Conform BlanketDisableCommandRule to SourceKitFreeRule (#5306) 2023-10-28 23:39:14 -07:00
Marcelo Fabri 491cf5e227 Conform InvalidSwiftLintCommandRule to SourceKitFreeRule (#5304) 2023-10-28 21:57:59 -07:00
Marcelo Fabri 8e34619576 Speed up closure_parameter_position when there are no violations (#5302) 2023-10-27 08:55:46 -07:00
BB9z cb3001bca2 Keep trailing trivia in explicit_init rule correction (#5296) 2023-10-23 15:41:10 -04:00
Danny Mösch 4c0f33782c Check disabled regions for all syntax types in parent rewriter class (#5292) 2023-10-23 15:34:51 -04:00
Danny Mösch 5ec1de0312 Generate makeRewriter optionally (#5281) 2023-10-17 15:19:19 -04:00
Danny Mösch 57632017e4 Introduce parent class for rewriters (#5282) 2023-10-17 18:55:02 +02:00
Danny Mösch 40bd97038a Support arbitrary configurations in @SwiftSyntaxRule (#5275)
Almost all rules based on SwiftSyntax can be set up now by just adding
`@SwiftSyntaxRule` to the rule struct.
2023-10-16 19:34:43 +02:00
Danny Mösch 73e6ba3067 Add parentheses to corrected opaque and existential optionals (#5278) 2023-10-15 06:43:43 -04:00
Danny Mösch 2ed1fc2f27 Let all rules be configurable (#5274) 2023-10-12 17:30:45 +02:00
Danny Mösch 58928b7e40 Enforce any on existential types (#5273)
This makes syntactically clear which types are rather expensive.
2023-10-12 08:37:23 +02:00
Danny Mösch 6438c77b96 Harmonize rule extensions (#5272) 2023-10-11 19:39:38 +02:00
Danny Mösch 0934c18cba Let RuleConfigurations be equatable by default (#5257) 2023-10-03 18:05:31 +02:00
Danny Mösch f6e5f778fc Configure expression folding by argument of @SwiftSyntaxRule macro (#5255) 2023-10-03 07:16:33 -04:00
Kotaro Suto 5d95b0adaf Make unneeded_break_in_switch auto correctable (#5188) 2023-10-03 04:31:10 -04:00
JP Simard 591154091e Introduce @SwiftSyntaxRule & @Fold macros (#5253)
These macros remove some of the boilerplate involved when writing rules.

This change also adds test infrastructure for the macros used within
SwiftLint.
2023-10-02 18:43:16 -04:00
Danny Mösch 2433e7b5bf Make use of macros to generate configuration parsing code (#5250) 2023-10-02 22:35:24 +02:00
John Szumski 696e19df33 Fix false positives in unused_import rule for constructors defined in transitive modules (#5246) 2023-10-01 11:19:41 +02:00
Danny Mösch 68b27d8310 Inline conditional examples requiring Swift 5.9 (#5249) 2023-09-30 09:56:54 -04:00
John Szumski 8517e9c8b7 Preserve @_exported import statements in unused_imports (#5242) 2023-09-30 08:47:17 -04:00
Tatsuyuki Kobayashi 1bbce6c1b0 Add only configuration option to todo rule (#5233) 2023-09-26 14:45:04 -04:00
Danny Mösch 075017cba5 Merge modifier extensions into one (#5234) 2023-09-24 23:50:10 +02:00
Danny Mösch d6b3f69804 Support switch expressions in switch_case_alignment rule (#5229)
The position of the closing brace now defines the alignment.
2023-09-20 17:43:01 -04:00
Ricky Tan 865f0227f6 Add new mode weak_except_iboutlets to implicitly_unwrapped_optional rule (#4975) 2023-09-15 22:15:42 +02:00
Danny Mösch 35a78815d1 Update SwiftSyntax (#5198) 2023-09-14 22:49:55 +02:00
Martin Redington 2df65169b0 Ignore 100 in no_magic_numbers rule (#5215) 2023-09-11 19:58:17 +02:00
Kishikawa Katsumi 05818b5375 Respect grapheme clusters in the collection_alignment rule (#5173)
Do so by counting characters. Solves (to some extent) the problem of apparent character counts not matching the UTF-8-based offsets returned by SwiftSyntax.
2023-09-11 19:45:53 +02:00
Tatsuyuki Kobayashi b609a4bebb Fix false positive in test_case_accessibility (#5212) 2023-09-08 10:12:55 -07:00
Martin Redington 8c68e80118 Check character before command in invalid_swiftlint_command rule (#5204) 2023-09-05 21:40:27 +02:00
Martin Redington 0c9827bc59 Add include_bare_init option to explicit_init rule (#5203) 2023-09-04 22:19:54 +02:00
Danny Mösch 02640a3415 Rewrite implicit_return rule using SwiftSyntax (#5166) 2023-09-02 14:32:37 +02:00
Danny Mösch e82fad944d Avoid monospaced rendering of description (#5202) 2023-09-02 05:52:28 -04:00
Danny Mösch 7504d54acd Use general rewrite infrastructure (#5201) 2023-09-02 05:28:16 -04:00
Matt Thompson b54d957426 Let private_swiftui_state rule also apply to @StateObject (#5200) 2023-09-01 17:16:02 -04:00
Danny Mösch be83b486ca Generalize alternative way to rewrite code (#5163) 2023-08-31 17:00:07 -04:00