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

unneeded_override breaks fixes for "Automatic Initializer Inheritance" #5571

Closed
2 tasks done
Lutzifer opened this issue May 13, 2024 · 7 comments · Fixed by #5579
Closed
2 tasks done

unneeded_override breaks fixes for "Automatic Initializer Inheritance" #5571

Lutzifer opened this issue May 13, 2024 · 7 comments · Fixed by #5579

Comments

@Lutzifer
Copy link
Contributor

New Issue Checklist

Describe the bug

In some cases (as can be seen in this Stack Overflow Issue: https://stackoverflow.com/a/28187653), it is necessary to reimplement initializers.

As these reimplementations are considered "unneeded" by SwiftLint, they are deleted.

"unneeded_override" could be made optional to avoid breaking existing codebases with this when running swiftlint fix.

@SimplyDanny
Copy link
Collaborator

Hm ... so is this rule useful for initializers at all? Feels like valid findings would be rare.

@Lutzifer
Copy link
Contributor Author

I think it has its uses for initializers, but the chance of breaking the build is too high.
If it was an opt-in-only rule it would be more clear which rule caused the issue.
Also, not-autofixing the initializers and instead showing a warning only would allow it to easily disable the rule for this very initializer if the situation outlined in the stack overflow issue occurs.

@SimplyDanny
Copy link
Collaborator

SimplyDanny commented May 14, 2024

Disabling the rule for a specific initializer should work anyway. Doesn't it?

As the rule has been available for the last two releases already, changing it to opt-in would be breaking and could lead to surprises. Not sure yet if we should do that.

@Lutzifer
Copy link
Contributor Author

Lutzifer commented May 14, 2024 via email

@marcelofabri
Copy link
Collaborator

The problem is that the rule implementation for autocorrect is not respecting the new affect_initializers configuration (which defaults to false). This means that linting behavior didn't change with the new release, but autocorrection did.

@Lutzifer
Copy link
Contributor Author

The problem is that the rule implementation for autocorrect is not respecting the new affect_initializers configuration (which defaults to false). This means that linting behavior didn't change with the new release, but autocorrection did.

that explains what we experienced

@SimplyDanny
Copy link
Collaborator

The problem is that the rule implementation for autocorrect is not respecting the new affect_initializers configuration (which defaults to false). This means that linting behavior didn't change with the new release, but autocorrection did.

Aha ... then this should be an easy fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants