-
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
0.55.0: Static Over Final Class warning occurs on overridable class property #5570
Comments
I'm seeing the same in my project, in other NSObject-derived classes. |
The intention of the "non-overridable" in the documentation is like "elements that cannot be overridden further should be marked In your example, |
Ah, thanks for that clarification Danny. If I replace Hopefully this GitHub issue will help others better understand as well! |
Perhaps it's better to remove the part "for non-overridable declarations" from the message entirely. Anyone willing to do that? 😄 |
If I did, I would explicitly add this case to the static over final documentation for both triggering and non-triggering examples since it calls out Xcode boilerplate code that's bound to trigger a violation upon project creation. However, my job prevents me from contributing to open source software so hopefully someone else can take the lead here 😅 |
Yeah, the wording of the warning here isn't clear. I took "non-overridable declarations" to mean methods that weren't overridden. |
I still find the wording to be confusing:
For this call site: final class SomeClass: NSObject {
@objc class func someFunc(...) The confusing part is that the error message says "over |
"Prefer static methods over class methods on final classes"? For interest: I'm honestly unclear what the benefit is to this rule — is it just for consistency? (It would seem not, given that it's only catching final classes). Is there any functional difference between a class method and a static method on a final class? |
TIL: This could be part of the confusion: I didn't know |
This is one aspect of the rule. They are both equivalent, so the rule suggests to prefer the shorter one. In final classes,
I don't think there is, at least not in Swift. Perhaps there are both Anyway, due to having two keywords, the prescribed meaning for Incidentally, the Swift compiler complains about My suggestions are "Prefer class C1 {
final class func f() {}
} and "Prefer final class C2 {
class func f() {}
} Does that make things clearer? |
New Issue Checklist
Describe the bug
In Xcode's boilerplate UITests launch tests code, they override a XCTest class property. This triggers a static over final class violation warning in SwiftLint 0.55.0.
The Static Over Final Class documentation mentions the warning should only populate for non-overridable declarations. Is this a bug?
The text was updated successfully, but these errors were encountered: