Skip to content
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

False positive for empty_xctest_method when assigning statements to _ #3691

Closed
2 tasks done
mildm8nnered opened this issue Aug 8, 2021 · 2 comments · Fixed by #4129
Closed
2 tasks done

False positive for empty_xctest_method when assigning statements to _ #3691

mildm8nnered opened this issue Aug 8, 2021 · 2 comments · Fixed by #4129
Labels
bug Unexpected and reproducible misbehavior. sourcekit-issue Issues that are caused by a misbehavior in SourceKit and need to be fixed upstream.

Comments

@mildm8nnered
Copy link
Collaborator

New Issue Checklist

Describe the bug

I'm getting a false positive for empty_xctest_method with code like the following:

    func testStuff() {
        _ = 4 + 4
    }

and

    func testStuff() {
        _ = 4 + 4
        _ = 4 + 4
    }

But not

    func testStuff() {
        let aaa = 4 + 4
    }

or

    func testStuff() {
        _ = 4 + 4
        let aaa = 4 + 4
    }

When these methods are members of a subclass of XCTestCase

Sample input:

import XCTest

class MyTests: XCTestCase {
    func testStuff() {
        _ = 4 + 4
    }
}
Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint --config swiftlint.yml  t.swift

Linting Swift files at paths t.swift
Linting 't.swift' (1/1)
/tmp/t.swift:4:5: warning: Empty XCTest Method Violation: Empty XCTest method should be avoided. (empty_xctest_method)
Done linting! Found 1 violation, 0 serious in 1 file.

Environment

  • SwiftLint version - 0.43.1
  • Installation method used - HomeBrew
  • Paste your configuration file:
opt_in_rules:
  - empty_xctest_method

No

  • Which Xcode version are you using (check xcodebuild -version)?
Xcode 12.4
Build version 12D4e
  • Do you have a sample that shows the issue?
import XCTest

class MyTests: XCTestCase {
    func testStuff() {
        _ = 4 + 4
    }
}
@KaneCheshire
Copy link
Contributor

I reported a similar (but different) issue with this rule here too a couple of months ago: #3647

@KaneCheshire
Copy link
Contributor

This looks like an issue with SourceKitten so I've opened an issue there and referenced this issue plus my other issue

@jpsim jpsim added the bug Unexpected and reproducible misbehavior. label Jan 20, 2022
@SimplyDanny SimplyDanny added the sourcekit-issue Issues that are caused by a misbehavior in SourceKit and need to be fixed upstream. label Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior. sourcekit-issue Issues that are caused by a misbehavior in SourceKit and need to be fixed upstream.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants