Commit Graph

2653 Commits

Author SHA1 Message Date
Iulian Onofrei 1950abb3b7 Fix incomplete example (#3396) 2020-10-28 12:45:00 -07:00
hank121314 9afc3bbfd9 [Fix] UnusedCaptureListRule: unowned self in @escaping closures (#3392)
* [Fix] `UnusedCaptureListRule`: should also handle unowned self
* [Docs] `CHANGELOG.md`: update.
2020-10-24 21:10:18 +03:00
Paul Taykalo 662db7be39 Fix correct .zero autocorrection (#3386) 2020-10-19 14:27:47 -07:00
Keith Smiley 5d6e25ae5f Add TestCaseAccessibilityRule (#3376)
Co-authored-by: JP Simard <jp@jpsim.com>
2020-10-12 08:59:45 -07:00
Sven Münnich da408b5901 Fix some false positives in rule explicit_self (#3368) 2020-09-25 09:23:03 -07:00
JP Simard 15c25abc47 Update SourceKitten to 0.30.1 (#3367) 2020-09-23 08:34:46 -07:00
JP Simard 2731f994d8 Fix issues with analyzer rules, Xcode 12 & SwiftUI (#3366)
We weren't properly handling some new Xcode 12 compiler logs.

We also were marking declarations used by SwiftUI as unused
(`@main` and preview providers).
2020-09-23 07:15:54 -07:00
JP Simard 4f8b7a5f48 release 0.40.3 2020-09-22 17:22:18 -04:00
Frederick Kellison-Linn 64b309e19e Fix false positives for 'multiple_closures_with_trailing_closure' (#3353) 2020-09-22 14:18:50 -07:00
JP Simard 494796b526 [UnusedDeclarationRule] Work around SR-11985 (#3363) 2020-09-22 10:00:16 -07:00
JP Simard a67b0f26e7 Revert "Fix finding the nested config when a single file path is passed (#3342)" (#3362)
This reverts commit ea06b79e0d.
2020-09-22 08:30:52 -07:00
Seth Friedman ea06b79e0d Fix finding the nested config when a single file path is passed (#3342)
Fixes #3341

When SwiftLint searches for nested configurations and only one file has been passed in via the `paths` argument, SwiftLint returns early after inadvertently comparing the containing directory of the file-to-be-linted to itself. This happens because `rootDirectory` is calculated from `rootPath`, which is set to the file being linted in this scenario.
2020-09-22 07:24:52 -07:00
JP Simard f71394a372 [UnusedDeclarationRule] Add more tests (#3359) 2020-09-21 12:10:46 -07:00
JP Simard 0ecf9a945b Don't mark @NSApplicationMain or @UIApplicationMain classes as unused (#3355) 2020-09-20 07:16:26 -07:00
hank121314 5e537fa821 [Fix] UnusedCaptureListRule: implicit self in @escaping closures (#3352)
## Summary

This pr fixes: #3267 .

Since Swift 5.3 is released. It support implicit self in @escaping closures([SE-0269](https://github.com/apple/swift-evolution/blob/master/proposals/0269-implicit-self-explicit-capture.md))

I think we should exclude self keyword from capture list rule.

## Test Plan

I have already add some test in example.

Thanks you so much for your code review!
2020-09-18 07:26:49 -07:00
JP Simard 6d2e8cfc06 Skip correcting files with parser diagnostics (#3349)
* Skip correcting files with parser diagnostics

Also fix many rule examples with parser diagnostics.

* Sourcery

* Link to issue in changelog entry
2020-09-17 18:14:00 -04:00
JP Simard 9b93b3efb8 [SwiftLintFile] Remove lock in favor of UUID (#3347)
We were using this lock to guarantee a new ID for every file, but we can
get that benefit by using values that are guaranteed to be unique
without the need for locks, such as a UUID.
2020-09-17 07:35:05 -07:00
JP Simard ea311bab23 [UnusedDeclarationRule] Speed up and detect more dead code (#3340)
By using SourceKit's `index` request to index the entire source file,
we can avoid having to make `cursor-info` requests for every candidate
token in the file, which scales linearly with the number of candiate
tokens.

For the Yams project, this approach improved the total SwiftLint run
time by 4.6x: 7.9 down from 36.8s.

The SourceKit index response doesn't have everything we need to identify
declarations, so we still need to make some `cursor-info` requests,
mostly to detect overrides: protocol conformances and parent class
overrides.

This approach ends up finding more unused declarations because the index
contains more declared USRs than can be found by calling `cursor-info`
on candidate tokens in a file.

---

Remove unused declaration in ArrayInitRule

---

Update package versions
2020-09-15 10:33:27 -07:00
JP Simard 9ab72060b6 release 0.40.2 2020-09-10 22:25:10 -04:00
Ryan Demo 51544bb4cc Add excluded_match_kinds custom rule config parameter (#3336)
This allows custom rules to define an `excluded_match_kinds` array instead of listing out all but one or a few of the `SyntaxKind`s in `match_kinds`. Rules that include both `match_kinds` and `excluded_match_kinds` will be invalid, since there's not an obvious way to resolve the two without an arbitrary priority between them.
2020-09-10 21:08:41 -04:00
Lukas Schmidt 8945038087 Use correct term for associated values
See https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html for reference
2020-09-03 11:26:57 +02:00
JP Simard 1a1db6c706 release 0.40.1 2020-08-27 11:33:45 -04:00
Marcelo Fabri da66a81710 release 0.40.0 2020-08-10 08:23:58 -07:00
Marcelo Fabri 5e1c13be52 Add unneeded_notification_center_removal rule
Fixes #2755
2020-08-10 07:46:51 -07:00
Marcelo Fabri 4756ce6b69 Ignore local vars and params 2020-08-05 21:46:33 -07:00
Marcelo Fabri bb372c2146 Fix false positives in extension_access_modifier with Swift 5.2 2020-08-05 21:36:09 -07:00
Marcelo Fabri 30c7add095 Change to .idiomatic 2020-08-05 15:11:41 -07:00
antonnazarov 09a0a216d1 Change types on string representation 2020-08-05 15:05:02 -07:00
antonnazarov 63bd8ce7a5 Add PreferZeroOverExplicitInitRule 2020-08-05 15:05:02 -07:00
Marcelo Fabri 89523a92a9 Merge pull request #3122 from lordzsolt/if-guard-case
Extend empty_enum_arguments rule to support `if case` and `guard case`
2020-08-05 14:51:55 -07:00
Janak Shah 6b3e4e64a0 Include IndexSet in byArrayLiteral collection 2020-08-05 13:03:46 +01:00
Zsolt Kovacs b33b86acd9 Extend empty_enum_arguments rule to support if case and guard case 2020-08-05 03:48:42 -07:00
Marcelo Fabri 0cabed81d7 Merge pull request #3283 from realm/marcelo/bugfix-3214
Use atexit on Linux
2020-08-05 03:47:33 -07:00
Marcelo Fabri 2d67213741 Merge pull request #3282 from realm/marcelo/self-and-is-multiple
Enable legacy_multiple and prefer_self_type_over_type_of_self in our codebase
2020-08-05 03:46:50 -07:00
Marcelo Fabri caedfcb62b Use atexit on Linux
Fixes #3214
2020-08-05 01:40:38 -07:00
Marcelo Fabri 8638d23aec Merge pull request #3281 from realm/marcelo/bugfix-3225
Trigger closure_parameter_position in free closures and capture lists
2020-08-05 01:12:22 -07:00
Marcelo Fabri f8ef7d649c Enable legacy_multiple and prefer_self_type_over_type_of_self in our codebase 2020-08-05 01:11:17 -07:00
Marcelo Fabri a05a87e7f2 Merge pull request #3258 from SimplyDanny/bugfix-3034
Fix #3034: Allow opening brace directly after another opening brace
2020-08-05 01:02:00 -07:00
Marcelo Fabri 6ec5806a93 Trigger closure_parameter_position in free closures and capture lists 2020-08-05 00:42:27 -07:00
Marcelo Fabri d36743b58a Fix false positive in no_space_in_method_call with multiple trailing closures
Fixes #3259
2020-08-04 21:20:54 -07:00
Marcelo Fabri 5ad5bf2dae Merge pull request #3276 from realm/marcelo/bugfix-3186
Fix false negative in `explicit_acl` rule with Swift 5.2+
2020-08-04 20:53:42 -07:00
Marcelo Fabri b541d253c6 Ignore .varParameter 2020-08-04 20:25:16 -07:00
Marcelo Fabri 1279523798 Ignore varLocal 2020-08-04 16:22:11 -07:00
Marcelo Fabri 0a592a34c9 Fix rule 2020-08-04 15:53:11 -07:00
Keith Smiley cf94d5d8ea Add IBInspectableInExtensionRule (#3174) 2020-08-04 14:15:40 -07:00
Marcelo Fabri 9e5557fbc5 Merge pull request #3160 from realm/mf-computed_accessors_order
Add computed_accessors_order rule
2020-08-04 05:04:45 -07:00
Marcelo Fabri 2d7702fc25 Fix false positive in explicit_acl rule with Swift 5.2+
Fixes #3186
2020-08-04 04:24:52 -07:00
Marcelo Fabri 28bec96b3e Remove a usage of “blacklist” 2020-08-04 04:00:36 -07:00
Tieme van Veen 5f8f9a5a3d Fix false positive UPPERCASE raw_value_for_camel_cased_codable_enum 2020-08-04 03:34:28 -07:00
Marcelo Fabri 240e25232f Add computed_accessors_order rule
Fixes #3158
2020-08-04 03:23:36 -07:00