Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implicit_getter false positive #5300

Merged
merged 7 commits into from Nov 9, 2023

Conversation

kabiroberai
Copy link
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
Copy link

SwiftLintBot commented Oct 25, 2023

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

Copy link
Collaborator

@SimplyDanny SimplyDanny left a comment

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.

@SimplyDanny
Copy link
Collaborator

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

@kabiroberai
Copy link
Contributor Author

@SimplyDanny do you know what Danger is complaining about?

@SimplyDanny
Copy link
Collaborator

@SimplyDanny do you know what Danger is complaining about?

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

@kabiroberai
Copy link
Contributor Author

@SimplyDanny looks like we're green!

@SimplyDanny SimplyDanny merged commit 92679e2 into realm:main Nov 9, 2023
12 checks passed
u-abyss pushed a commit to u-abyss/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.

None yet

3 participants