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

Potentially Crucial Custom Rules Bug #1558

Closed
tinder-cfuller opened this issue May 23, 2017 · 3 comments
Closed

Potentially Crucial Custom Rules Bug #1558

tinder-cfuller opened this issue May 23, 2017 · 3 comments
Labels
bug Unexpected and reproducible misbehavior.

Comments

@tinder-cfuller
Copy link
Contributor

tinder-cfuller commented May 23, 2017

Issue Description

Disabling just one custom rule, actually disables all custom rules.

STR

1) SwiftLint Config

Create config file named .swiftlint.yml with the following contents:

custom_rules:
  hello_rule:
    regex: "Hello"
    match_kinds: string
  world_rule:
    regex: "World"
    match_kinds: string

2) Swift Test File

Create test file named Example.swift with the following contents:

class Example {

    func example() -> String {
        return "Hello World!"
    }

}

3) Run SwiftLint

When running SwiftLint, we successfully get the following output:

Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'example.swift' (1/1)
/PATH_OBSCURED/example.swift:4:17: warning: hello_rule Violation: Regex matched. (hello_rule)
/PATH_OBSCURED/example.swift:4:23: warning: world_rule Violation: Regex matched. (world_rule)
Done linting! Found 2 violations, 0 serious in 1 file.

As you can see ☝️ both rules are violated.

4) Disable One Rule

In the test file, disable only the world_rule:

class Example {

    // swiftlint:disable world_rule
    func example() -> String {
        return "Hello World!"
    }

}

5) Run SwiftLint Again

When running SwiftLint now, we get the following output:

Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'example.swift' (1/1)
Done linting! Found 0 violations, 0 serious in 1 file.

As you can see ☝️ there are no violations, when in fact, the hello_rule violation should be reported.

Additional Info

This has been tested with various scenarios and the experience is consistently that disabling one custom rule, actually disables all custom rules. This also occurs with :previous, :this, :next.

This issue appears to only affects custom rules, not built-in rules.

@tinder-cfuller
Copy link
Contributor Author

tinder-cfuller commented May 23, 2017

Test Files

swiftlint-custom-rules-bug.zip

@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label May 24, 2017
@jpsim
Copy link
Collaborator

jpsim commented Jun 3, 2017

Thanks for reporting this. Filed a PR fixing this in #1603.

@tinder-cfuller
Copy link
Contributor Author

@jpsim Awesomeness 👍

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

3 participants