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 in test_case_accessibility for variables used in init #5211

Closed
2 tasks done
laralove143 opened this issue Sep 8, 2023 · 1 comment · Fixed by #5212
Closed
2 tasks done

False positive in test_case_accessibility for variables used in init #5211

laralove143 opened this issue Sep 8, 2023 · 1 comment · Fixed by #5212

Comments

@laralove143
Copy link
Contributor

New Issue Checklist

Describe the bug

When defining variables with let or var inside the init block, test_case_accessibility warning is raised, when it shouldn't be. Maybe they're falsely being treated as properties?

Complete output when running SwiftLint, including the stack trace and command used

Command output:

ProjectTests % swiftlint BaseTestCase.swift
Linting Swift files at paths BaseTestCase.swift
Linting 'BaseTestCase.swift' (1/1)
.../Project/Tests/ProjectTests/BaseTestCase.swift:6:9: warning: Test Case Accessibility Violation: Test cases should only contain private non-test members (test_case_accessibility)
.../Project/Tests/ProjectTests/BaseTestCase.swift:7:9: warning: Test Case Accessibility Violation: Test cases should only contain private non-test members (test_case_accessibility)
Done linting! Found 2 violations, 0 serious in 1 file.

Environment

  • SwiftLint version: 0.52.4
  • Installation method used: Homebrew
  • Paste your configuration file:
opt_in_rules:
  - test_case_accessibility
  • Are you using nested configurations: No
  • Which Xcode version are you using: Xcode 14.3.1 Build version 14E300c
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
import XCTest

class BaseTestCase: XCTestCase {
    override init() {
        super.init()
        let foo = 1 // test_case_accessibility
        var bar = 2 // test_case_accessibility
    }
}
@gibachan
Copy link
Contributor

gibachan commented Sep 8, 2023

I would like to try this issue 🙋‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants