-
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
explicit_init - creating an instance from a meta-type #984
Comments
Are you sure this example triggers? I couldn't reproduce on SwiftLint 0.13.2:
|
@marcelofabri my fault, I didn't do linting, just shown the idiom. Here is the snipped that does produce the warning:
Output:
|
The rule currently uses a regex to check if it's a type or metatype, so changing It would be better to check if it was indeed a type or variable, but we currently don't have this information AFAIK and both a type ( |
@marcelofabri Thank you for explanation. I thought it is possible to infer the type, as swiftlint hooked into Clang and SourceKit. Unfortunately, lowercasing the var name here loses the semantics I'd like to preserve. Nevertheless, this particular example, could be fixed in this way, I have other cases, where I was in need to go with |
Possible yes, but not implemented. Would require a new "compiled" mode that SwiftLint could run in such as the one described in #829 (comment). |
This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions! |
Creating an instance from meta-types via explicit
init()
is a common idiom. Currently, swiftlint highlights instructions like this whenexplicit_init
rule is opted-in.The text was updated successfully, but these errors were encountered: