-
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
Add test_parent_classes
option to single_test_class
, balanced_xctest_lifecycle
, and empty_xctest
rules
#4233
Conversation
…rules' of github.com:mildm8nnered/SwiftLint into mildm8nnered-add-test-parent-class-option-to-more-test-rules
Generated by 🚫 Danger |
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.
There is a lot of redundancy in the configurations.
BalancedXCTestLifecycleConfiguration
andEmptyXCTestMethodConfiguration
are identical, andSingleTestClassConfiguration
differs only in includingQuickSpec
as an additional default parent class.
QuickSpec
also inherits from XCTestCase
and thus should be in the default set of all of the configurations. This is an improvement for a follow-up change, though.
I didn't roll anything up as yet, but obviously it would be trivial to either have an abstract parent class, or to have two of the configurations inherit from the other one, and to take the default parent classes as a constructor argument.
We could have one configuration struct used by all the rules when all have QuickSpec
in their default set. For now, it's fine to have multiple configurations.
Also, I had to implement
makeViolation(file: SwiftLintFile, position: AbsolutePosition) -> StyleViolation
myself inEmptyXCTestMethodRule
because my rule's configuration was no longer aSeverityConfiguration
- I wonder if there some way I could have avoided having to do that.
Currently, there is no way to avoid it. Up to now, only a handful of rules require manual implementation.
|
||
public var consoleDescription: String { | ||
return severityConfiguration.consoleDescription + | ||
", test_parent_classes: [\(testParentClasses)]" |
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.
The brackets are superfluous. Sorting the set makes the output deterministic:
", test_parent_classes: [\(testParentClasses)]" | |
", test_parent_classes: \(testParentClasses.sorted())" |
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.
So I added QuickSpec
to all the defaults, and rolled the new ones up, with typealiases for the names you'd expect.
But I bodged rebasing, so I just moved to a new branch and PR - #4262
Replaced by #4262 |
Adds a
test_parent_classes
option to thesingle_test_class
,balanced_xctest_lifecycle
, andempty_xctest
rules, resolving the remaining rules mentioned in #4200.Very similar to #4214 but see notes below.
For example, given
The following configurations will pick up the violations:
Notes
There is a lot of redundancy in the configurations.
BalancedXCTestLifecycleConfiguration.swift
andEmptyXCTestMethodConfiguration.swift
are identical, andSingleTestClassConfiguration.swift
differs only in includingQuickSpec
as an additional default parent class.I didn't roll anything up as yet, but obviously it would be trivial to either have an abstract parent class, or to have two of the configurations inherit from the other one, and to take the default parent classes as a constructor argument.
Also, I had to implement
makeViolation(file: SwiftLintFile, position: AbsolutePosition) -> StyleViolation
myself inEmptyXCTestMethodRule.swift
because my rule's configuration was no longer a SeverityConfiguration - I wonder if there some way I could have avoided having to do that.