-
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
empty_xctest_method
incorrectly triggering for setUpWithError and tearDownWithError
#3647
Comments
I've tried the latest release (0.44.0) but this is still an issue for us 😞 |
Looks like an issue with SourceKit according to SourceKitten (see closed issue above), however I'm now trying to understand why it worked with version 0.38.0 of SwiftLint but downloading the latest version has the issue. Surely the toolchain is the same between the two when running in Xcode? |
Perhaps a workaround for now would be to make this more configurable so it doesn't have to impact setup/teardown functions |
I suspect this is related: empty_xctest_method is triggering on variable functions declared within an XCTestCase class, too. This triggering code comes straight from the Xcode 13 iOS App template (when “Include tests” is selected): override class var runsForEachTargetApplicationUIConfiguration: Bool {
true
} |
This is still an issue with version 0.47.1 and we've had to either disable the rule or add a call to a function like super.setup() to silence the warnings |
New Issue Checklist
Describe the bug
Currently on
master
, theempty_xctest_method
rule is incorrectly triggered for overriddensetUpWithError
andtearDownWithError
methods in some cases.If you update
EmptyXCTestMethodRuleExamples.nonTriggeringExamples
to include a new non-triggering example with one of the following, theEmptyXCTestMethodRuleTests.testWithDefaultConfiguration
unit test will fail:or
If we update it to add a (redundant)
super
call it fixes the issue:However there are two issues with this:
Additionally, this has only started failing since updating SwiftLint, we had this rule enabled in 0.38.0 but building the latest version from
master
and using that causes a failure. I'm not sure exactly what version since 0.38.0 this started happening.Looking at the
EmptyXCTestMethodRule
implementation and putting a breakpoint where theStyleViolation
is returned, we can see that bothenclosedVarParameters
andsubstructure
are showing as empty for thefunctionMethodInstance
subDictionary
, and that's what's causing the violation.If I also
po dictionary
at the same breakpoint, I can't see any way of detecting that the function isn't actually empty. It's like thatfoobar = ""
doesn't exist in the source.I'm not too savvy with SourceKitten to know if this is a bug with SourceKitten, but since the function isn't actually empty, this is a bit of an issue.
Environment
The text was updated successfully, but these errors were encountered: