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

typesafe_array_init rule reports violations as though they were of the array_init rule. #5709

Closed
2 tasks done
mildm8nnered opened this issue Jul 28, 2024 · 1 comment
Closed
2 tasks done
Labels
bug Unexpected and reproducible misbehavior.

Comments

@mildm8nnered
Copy link
Collaborator

New Issue Checklist

Describe the bug

The TypesafeArrayInitRule outsources some of its functionality to the ArrayInitRule. The violations are reported as being of array_init rather than typesafe_array_init.

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

typesafe_array_init is an analyzer rule, so it's hard to run the analyzer on it in isolation, but the following unit test illustrates the problem:

final class TypesafeArrayInitRuleTests: SwiftLintTestCase {
    func testViolationRuleIdentifier() {
        let baseDescription = TypesafeArrayInitRule.description
        guard let triggeringExample = baseDescription.triggeringExamples.first else {
            XCTFail("No triggering examples found")
            return
        }
        guard let config = makeConfig(nil, baseDescription.identifier) else {
            XCTFail("Failed to create configuration")
            return
        }
        let violations = SwiftLintFrameworkTests.violations(triggeringExample, config: config, requiresFileOnDisk: true)
        XCTAssertGreaterThanOrEqual(violations.count, 1)
        XCTAssertEqual(violations.first?.ruleIdentifier, baseDescription.identifier)
    }
}

This will fail the final check, as the types of the violations will not be typesafe_array_init

@mildm8nnered
Copy link
Collaborator Author

Resolved by #5710

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
Development

No branches or pull requests

1 participant