-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Unneeded Synthesized Initializer removes needed initializers with property wrappers #5153
Comments
See https://realm.github.io/SwiftLint/unneeded_synthesized_initializer.html This is currently broken (realm/SwiftLint#5153) which leads to `swiftlint --autocorrect` removing actually needed code.
See https://realm.github.io/SwiftLint/unneeded_synthesized_initializer.html This is currently broken (realm/SwiftLint#5153) which leads to `swiftlint --autocorrect` removing actually needed code.
See https://realm.github.io/SwiftLint/unneeded_synthesized_initializer.html This is currently broken (realm/SwiftLint#5153) which leads to `swiftlint --autocorrect` removing actually needed code.
To add to this, it also removes initializers that just apply property wrappers to the arguments (it does not seem to trigger the rule in the linting digest?) struct Title {
let text: String
let color: Color
let font: Font
init(
@Localised text: String, // 👈 some property wrapper that alters the input
color: Color,
font: Font
) {
self.text = text
self.color = color
self.font = font
}
} weirder still, it will produce a "Superfluous Disable Command Violation" warning if disabled // swiftlint:disable:next unneeded_synthesized_initializer // 👈 stops the removal but produces a superfluous warning
init(
@Localised text: String, swiftlint version: 0.55.1 |
This is addressed by #5594.
I'm unable to reproduce this. The disable command works as expected in my little test setup. |
@NachoSoto: Taking a look at your initially reported example, I wonder why |
@NachoSoto, @aclima93: Are these still issues for you? |
Yeah, this got fixed after the 0.55.1 release only. |
@SimplyDanny will your fix also address the scenario when the initializer is marked |
Ah - I thought I saw an issue relating to this recently in the periphery codebase |
It doesn't. I wonder if initializers with any type of attribute should be excluded. |
New Issue Checklist
Describe the bug
This new rule correct actually needed initializers. Example:
SwiftLint
removes that constructor, but it is required to be able to initialize it with a value of typeE
instead of@PropertyWrapper<E>
Environment
The text was updated successfully, but these errors were encountered: