SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

Rewrite `ibinspectable_in_extension` with SwiftSyntax

Open jpsim opened this issue 2 years ago • 3 comments

jpsim avatar Sep 19 '22 19:09 jpsim

To make the rule even faster especially in huge source files, traversing the AST could be stopped as soon as a class, struct or enum is encountered as only extension are relevant. This is done for example in EmptyXCTestMethodRule. I cannot tell, though, whether this really has a benefit in speed, but an advantage in huge ASTs is conceivable.

SimplyDanny avatar Sep 19 '22 20:09 SimplyDanny

4 Warnings
:warning: If this is a user-facing change, please include a CHANGELOG entry to credit yourself!
You can find it at CHANGELOG.md.
:warning: This PR may need tests.
:warning: This PR introduced a violation in Kickstarter: /Library/UINavigationItem+Localized.swift:15:5: warning: IBInspectable in Extension Violation: Extensions shouldn't add @IBInspectable properties. (ibinspectable_in_extension)
:warning: This PR introduced a violation in Kickstarter: /Library/UINavigationItem+Localized.swift:4:3: warning: IBInspectable in Extension Violation: Extensions shouldn't add @IBInspectable properties. (ibinspectable_in_extension)
14 Messages
:book: Linting Aerial with this PR took 0.12s vs 0.22s on main (45% faster)
:book: Linting Alamofire with this PR took 0.08s vs 0.3s on main (73% faster)
:book: Linting Firefox with this PR took 0.33s vs 1.44s on main (77% faster)
:book: Linting Kickstarter with this PR took 0.46s vs 1.98s on main (76% faster)
:book: Linting Moya with this PR took 0.13s vs 0.16s on main (18% faster)
:book: Linting Nimble with this PR took 0.08s vs 0.16s on main (50% faster)
:book: Linting Quick with this PR took 0.06s vs 0.08s on main (25% faster)
:book: Linting Realm with this PR took 0.4s vs 1.1s on main (63% faster)
:book: Linting SourceKitten with this PR took 0.07s vs 0.13s on main (46% faster)
:book: Linting Sourcery with this PR took 0.18s vs 0.44s on main (59% faster)
:book: Linting Swift with this PR took 0.72s vs 0.9s on main (20% faster)
:book: Linting WordPress with this PR took 0.53s vs 2.29s on main (76% faster)
:book: This PR fixed a violation in Kickstarter: /Library/UINavigationItem+Localized.swift:16:12: warning: IBInspectable in Extension Violation: Extensions shouldn't add @IBInspectable properties. (ibinspectable_in_extension)
:book: This PR fixed a violation in Kickstarter: /Library/UINavigationItem+Localized.swift:5:3: warning: IBInspectable in Extension Violation: Extensions shouldn't add @IBInspectable properties. (ibinspectable_in_extension)

Here's an example of your CHANGELOG entry:

* Rewrite `ibinspectable_in_extension` with SwiftSyntax.  
  [jpsim](https://github.com/jpsim)
  [#issue_number](https://github.com/realm/SwiftLint/issues/issue_number)

note: There are two invisible spaces after the entry's text.

Generated by :no_entry_sign: Danger

SwiftLintBot avatar Sep 19 '22 22:09 SwiftLintBot

Yes, good point @SimplyDanny, I'll see if I can do that here.

jpsim avatar Sep 20 '22 20:09 jpsim