-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix custom_rules regression introduced in #4755 #5336
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here's an example of your CHANGELOG entry: * Fix custom_rules regression introduced in #4755.
[marcelofabri](https://github.com/marcelofabri)
[#issue_number](https://github.com/realm/SwiftLint/issues/issue_number) note: There are two invisible spaces after the entry's text. Generated by 🚫 Danger |
Looks like this might not be enough, with this commit I still see the issue, here's another example: if UIAccessibility.isVoiceOverRunning { // swiftlint:disable:this use_voice_over_provider
return
}
|
took a quick look and couldn't repro it with a unit test: func testSuperfluousDisableCommandDoesntTriggerWithCustomRulesDisableThis() throws {
let customRulesConfiguration: [String: Any] = [
"use_voice_over_provider": [
"regex": "\\bUIAccessibility\\.isVoiceOverRunning\\b",
"match_kinds": ["identifier", "typeidentifier"]
]
]
let example = Example(
"""
if UIAccessibility.isVoiceOverRunning {} // swiftlint:disable:this use_voice_over_provider
""",
configuration: customRulesConfiguration
).skipWrappingInCommentTest()
let configuration = try XCTUnwrap(makeConfig(["custom_rules": customRulesConfiguration], "custom_rules"))
let violations = violations(example, config: configuration)
XCTAssertEqual(violations.count, 0)
} i'll try to dig deeper tonight, but i'm inclined to just revert the PR. |
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Here's what was happening:
CustomRules.swift
filters out violations outside of disabled regionsLinter
so we'll always triggersuperfluous_disable_command
Region.isRuleEnabled
doesn't understand custom rulesWe can change the logic a little bit to make it work for custom rules. I don't love this, but I think it works (and we already special case
CustomRules
in a few places).