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

Allow unused_setter_value for overrides #3653

Merged
merged 5 commits into from
Jan 20, 2022

Conversation

grosem
Copy link
Contributor

@grosem grosem commented Jun 8, 2021

Fixes #2585. Happy to make changes if necessary 😎

@SwiftLintBot
Copy link

SwiftLintBot commented Jun 8, 2021

1 Warning
⚠️ This PR may need tests.
21 Messages
📖 Linting Aerial with this PR took 0.24s vs 0.23s on master (4% slower)
📖 Linting Alamofire with this PR took 0.27s vs 0.27s on master (0% slower)
📖 Linting Firefox with this PR took 1.08s vs 1.07s on master (0% slower)
📖 Linting Kickstarter with this PR took 1.83s vs 1.83s on master (0% slower)
📖 Linting Moya with this PR took 0.12s vs 0.12s on master (0% slower)
📖 Linting Nimble with this PR took 0.13s vs 0.13s on master (0% slower)
📖 Linting Quick with this PR took 0.07s vs 0.07s on master (0% slower)
📖 Linting Realm with this PR took 0.79s vs 0.79s on master (0% slower)
📖 Linting SourceKitten with this PR took 0.11s vs 0.11s on master (0% slower)
📖 Linting Sourcery with this PR took 0.38s vs 0.38s on master (0% slower)
📖 Linting Swift with this PR took 1.18s vs 1.17s on master (0% slower)
📖 Linting WordPress with this PR took 1.98s vs 1.98s on master (0% slower)
📖 This PR fixed a violation in Firefox: /Client/Frontend/Login Management/LoginDetailTableViewCell.swift:80:9: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)
📖 This PR fixed a violation in Firefox: /Client/Frontend/Settings/AppSettingsOptions.swift:177:9: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/Utility/WPMediaEditor.swift:41:9: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Post/AuthorFilterViewController.swift:63:9: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Post/Preview/PreviewDeviceSelectionViewController.swift:87:9: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Reader/Detail/ReaderDetailViewController.swift:128:9: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Stats/Insights/Posting Activity/PostingActivityCell.swift:48:9: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Stats/Insights/Posting Activity/PostingActivityMonth.swift:180:9: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)
📖 This PR fixed a violation in WordPress: /WordPress/Classes/ViewRelated/Stats/Insights/Posting Activity/PostingActivityMonth.swift:40:9: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)

Generated by 🚫 Danger

@marcelofabri
Copy link
Collaborator

@grosem what do you think about checking that the set body is empty? I feel like this change as is could end up introducing issues on overrides where the author would want to use newValue but made a mistake.

@grosem
Copy link
Contributor Author

grosem commented Jun 25, 2021

Makes sense, I'll try to add that 👍

@grosem grosem marked this pull request as draft July 6, 2021 23:34
@grosem grosem marked this pull request as ready for review July 6, 2021 23:34
@grosem grosem marked this pull request as draft July 6, 2021 23:35
@grosem
Copy link
Contributor Author

grosem commented Jul 10, 2021

@marcelofabri I tried to find the easiest way to accomplish that, what do you think?
The checks still run into an error here which I cannot reproduce locally - not really sure what the problem is.

@grosem grosem marked this pull request as ready for review July 10, 2021 08:20
@zvonicek
Copy link

zvonicek commented Nov 8, 2021

Hi, thanks for this PR! I'm seeing a similar problem in my codebase and would like to see the PR merged. Can you try to revive this PR @grosem?

Current problem I'm seeing in the checks on this PR – Closure expressions should have a single space inside each brace. – seem to be because you are missing a space characters inside of the contains(where:) closure in UnusedSetterValueRule.swift line 159.

Instead of contains(where: {!$0.isCommentLike}) try to write it as contains(where: { !$0.isCommentLike }).

@grosem
Copy link
Contributor Author

grosem commented Nov 8, 2021

Hi, thanks for this PR! I'm seeing a similar problem in my codebase and would like to see the PR merged. Can you try to revive this PR @grosem?

Current problem I'm seeing in the checks on this PR – Closure expressions should have a single space inside each brace. – seem to be because you are missing a space characters inside of the contains(where:) closure in UnusedSetterValueRule.swift line 159.

Instead of contains(where: {!$0.isCommentLike}) try to write it as contains(where: { !$0.isCommentLike }).

Sure thing, thank you for your comment. In my local version I had that already fixed but didn't commit it for a reason I cannot remember... if there is anything else to adjust, please let me know!

@zvonicek
Copy link

Thanks for the fix! The PR now seem to pass, hope we can get someone to review and merge this.

@jpsim jpsim force-pushed the allow-unused-setter-for-overrides branch from 674f480 to 4274887 Compare January 20, 2022 22:22
@jpsim jpsim enabled auto-merge (squash) January 20, 2022 22:24
@jpsim
Copy link
Collaborator

jpsim commented Jan 20, 2022

Thanks for the contribution!

@jpsim jpsim merged commit c90c329 into realm:master Jan 20, 2022
get {
return Persister.shared.aValue
}
set() { }

Choose a reason for hiding this comment

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

These examples get automatically run as tests, right?

This example fails for me, on v0.46.2

echo 'private var abc: Int { get { 123 } set() { } }' | swiftlint lint --no-cache --use-stdin --enable-all-rules
<nopath>:1:36: warning: Unused Setter Value Violation: Setter value is not used. (unused_setter_value)
Done linting! Found 1 violation, 0 serious in 1 file.

Can you reproduce?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes these are run as tests, please open a new issue with full steps to reproduce, what you're seeing and what you're expecting.

Choose a reason for hiding this comment

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

Opened #3863 :)

rcole34 pushed a commit to rcole34/SwiftLint that referenced this pull request Feb 22, 2022
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.

unused_setter_value incorrectly triggers for overridden properties.
6 participants