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

Warnings for deprecated rules that are implicitly enabled using the all rule #4989

Closed
2 tasks done
sdc-78 opened this issue May 11, 2023 · 9 comments · Fixed by #5014
Closed
2 tasks done

Warnings for deprecated rules that are implicitly enabled using the all rule #4989

sdc-78 opened this issue May 11, 2023 · 9 comments · Fixed by #5014
Labels
discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions.

Comments

@sdc-78
Copy link

sdc-78 commented May 11, 2023

New Issue Checklist

Describe the bug

SwiftLint gives warnings for deprecated rules that are implicitly enabled using the all rule :

warning: The `anyobject_protocol` rule is now deprecated and will be completely removed in a future release.
warning: The `inert_defer` rule is now deprecated and will be completely removed in a future release due to an equivalent warning issued by the Swift compiler.
warning: The `unused_capture_list` rule is now deprecated and will be completely removed in a future release due to an equivalent warning issued by the Swift compiler.

Environment

  • SwiftLint 0.52
  • Relevant configuration file part:
opt_in_rules:
  - all
@SimplyDanny
Copy link
Collaborator

While they are deprecated they are still valid rules. So I would expect them to be enabled by the all key. Thus, I wouldn't change this behavior.

If you don't want the rules to be enabled, explicitly disable them. The warning appears no matter how the rules were enabled. If you like the rules, you enable them but you have to live with the warning. That's independent from the all key.

@SimplyDanny SimplyDanny added the discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions. label May 11, 2023
@sdc-78
Copy link
Author

sdc-78 commented May 11, 2023

I agree that deprecated rules should remain enabled by all, as long as they still exist.
I'm only suggesting that they not be reported as deprecated, as they haven't been explicitly enabled.

@SimplyDanny
Copy link
Collaborator

Well, with all a user has explicitly enabled them. That they are deprecated doesn't play a role. For a set of users they might still be useful.

@sdc-78
Copy link
Author

sdc-78 commented May 11, 2023

For a set of users they might still be useful.

I actually hadn't thought of that. What type of use/users are you thinking of?

@SimplyDanny
Copy link
Collaborator

inert_defer for example has been deprecated because the Swift compiler reports the same violation natively in recent versions. For people relying on an older Swift version, the rule still has it's benefit.

@mildm8nnered
Copy link
Collaborator

I don't think it would be too outrageous to have a command line argument that suppressed the deprecated rule warnings though.

In a private experimental branch I've got an implementation of a configuration "wizard" for SwiftLint, and there I marked all the deprecated rules with a DeprecatedRule protocol, so that I can offer the user the option of disabling any deprecated rules.

A similar mechanism could be extended to support a command line argument to suppress the deprecation warnings ...

@sdc-78
Copy link
Author

sdc-78 commented May 12, 2023

inert_defer for example has been deprecated because the Swift compiler reports the same violation natively in recent versions. For people relying on an older Swift version, the rule still has it's benefit.

I agree that deprecated rules still may be useful and I never asked to stop enabling them!

@N-ihad
Copy link

N-ihad commented Jun 7, 2024

what's the reason behind deprecating 'unused_capture_list'? Swift compiler doesn't seem to be reporting about that, so what's the catch?

@SimplyDanny
Copy link
Collaborator

Which version of the Swift compiler are you using and on which example?

Compiling

func f(x: Int) {
    { [x] in }()
}

prints out

main.swift:2:8: warning: capture 'x' was never used
    { [x] in }()
       ^

which unused_capture_list is supposed to report as well and which thus draws the rule deprecated.

I'm using Swift 5.10. But as the rule got deprecated 18 months ago already, I assume that at least 5.8 should be complaining too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Topics that cannot be categorized as bugs or enhancements yet. They require further discussions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants