-
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
Ignore no_magic_numbers
violations if they are in an extension of a test class (only works in the same file)
#5146
Conversation
d423c44
to
fd94ec1
Compare
no_magic_numbers
violations if they are in an extension of a test class (only works in the same file)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I like how you achieve to traverse the AST only once!
Yet, like so often, I have some remarks ...
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoMagicNumbersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoMagicNumbersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoMagicNumbersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoMagicNumbersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoMagicNumbersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoMagicNumbersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoMagicNumbersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoMagicNumbersRule.swift
Outdated
Show resolved
Hide resolved
Source/SwiftLintBuiltInRules/Rules/Idiomatic/NoMagicNumbersRule.swift
Outdated
Show resolved
Hide resolved
1fffbb4
to
77006c2
Compare
My heart always sinks a little at first, but the code ends up so much better for your feedback :-) I wish I got code reviews like that in my day job. |
Haha ... thank you for the kind feedback! I appreciate your continuous and well thought out contributions. |
…test class (only works in the same file)
f836039
to
7d21b47
Compare
This reverts commit 7d21b47.
Ignores violations if they are present in an extension, if that extension extends a child of the specified
testParentClasses
, as long as the class declaration is in the same source file.Partially resolves #5137
This was harder that I thought, and also more useful than expected, given the number of violations this (apparently correctly) fixes in the OSS tests.
We now keep track of class declarations, and whether they inherit from
testParentClasses
or not.When we see a violation in an extension, unless we already know that it extends a test class, we add it to the violations.
If later in the file, we see the class declaration, and it extends one of the
testParentClasses
, we remove the violations from the list.This should work no matter where in the file the class declaration occurs.