Skip to content

Fix implicit_getter false positive#5300

Merged
SimplyDanny merged 7 commits into
realm:mainfrom
kabiroberai:kabir/better-implicit-getter
Nov 9, 2023
Merged

Fix implicit_getter false positive#5300
SimplyDanny merged 7 commits into
realm:mainfrom
kabiroberai:kabir/better-implicit-getter

Conversation

@kabiroberai

Copy link
Copy Markdown
Contributor

The implicit_getter rule wasn't aware of the init accessor (SE-0400), causing it to incorrectly trigger on the following example

var foo: String {
  init { ... }
  get { ... } // implicit_getter violation
}

Rather than adding a check for initAccessor I updated the check to bail early unless accessorsList has a single element, that being get. This allows for forwards-compatibility if another accessor variant were to be introduced in the future. Semantically, IIUC this rule should only trigger in the aforementioned case that there's one accessor and that accessor is get — otherwise it isn't possible to elide the keyword.

@SwiftLintBot

SwiftLintBot commented Oct 25, 2023

Copy link
Copy Markdown
16 Messages
📖 Linting Aerial with this PR took 1.19s vs 1.19s on main (0% slower)
📖 Linting Alamofire with this PR took 1.56s vs 1.57s on main (0% faster)
📖 Linting Brave with this PR took 8.92s vs 8.91s on main (0% slower)
📖 Linting DuckDuckGo with this PR took 4.49s vs 4.5s on main (0% faster)
📖 Linting Firefox with this PR took 10.44s vs 10.44s on main (0% slower)
📖 Linting Kickstarter with this PR took 11.0s vs 10.99s on main (0% slower)
📖 Linting Moya with this PR took 0.61s vs 0.63s on main (3% faster)
📖 Linting NetNewsWire with this PR took 3.28s vs 3.28s on main (0% slower)
📖 Linting Nimble with this PR took 0.82s vs 0.82s on main (0% slower)
📖 Linting PocketCasts with this PR took 8.8s vs 8.78s on main (0% slower)
📖 Linting Quick with this PR took 0.39s vs 0.39s on main (0% slower)
📖 Linting Realm with this PR took 11.68s vs 11.66s on main (0% slower)
📖 Linting Sourcery with this PR took 2.81s vs 2.82s on main (0% faster)
📖 Linting VLC with this PR took 1.55s vs 1.55s on main (0% slower)
📖 Linting Wire with this PR took 19.63s vs 19.64s on main (0% faster)
📖 Linting WordPress with this PR took 13.32s vs 13.31s on main (0% slower)

Generated by 🚫 Danger

@SimplyDanny SimplyDanny left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks!

Please also add an entry to the CHANGELOG to credit yourself and let others know about the fix.

Comment thread Source/SwiftLintBuiltInRules/Rules/Style/ImplicitGetterRule.swift Outdated
@SimplyDanny

Copy link
Copy Markdown
Collaborator

You need to remove the swiftlint:disable command here now to make the tests pass.

@kabiroberai

Copy link
Copy Markdown
Contributor Author

@SimplyDanny do you know what Danger is complaining about?

@SimplyDanny

Copy link
Copy Markdown
Collaborator

@SimplyDanny do you know what Danger is complaining about?

It doesn't like merge commits. Please rebase and force-push instead.

@kabiroberai kabiroberai force-pushed the kabir/better-implicit-getter branch from 4b25fbe to 9f9ebc1 Compare November 7, 2023 08:36
@kabiroberai

Copy link
Copy Markdown
Contributor Author

@SimplyDanny looks like we're green!

@SimplyDanny SimplyDanny merged commit 92679e2 into realm:main Nov 9, 2023
yuya-okuse pushed a commit to yuya-okuse/SwiftLint that referenced this pull request Dec 16, 2023
MartijnAmbagtsheer pushed a commit to MartijnAmbagtsheer/SwiftLint that referenced this pull request Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants