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

superfluous_disable_command reports violations on words in comment that are not rules #2623

Closed
mbarthelemy opened this Issue Feb 1, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@mbarthelemy
Copy link

mbarthelemy commented Feb 1, 2019

New Issue Checklist

Describe the bug

Swiftlint reports violations for extraneous words in the same comment that follow the swiftlint rule. Many of our team have written disables that look like the one below in the example. Swiftlint should not report a violation for words that it finds that are not known rules.

The example below also reports the correct violation 79 times when I would expect only one. In combination this results in excessive reporting in some situations with the 7 lines of code below reporting 869 violations which is 11 full repeats.

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Linting Swift files at paths 
Linting 'File.swift' (1/1)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'no_indentation_spaces' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'no_indentation_spaces' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'no_indentation_spaces' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
...
[deleted 813 lines]
...
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'no_indentation_spaces' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'no_indentation_spaces' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'no_indentation_spaces' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:1:73: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'as' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'this' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'doesn't' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'expected' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
File.swift:6:42: warning: Superfluous Disable Command Violation: SwiftLint rule 'work' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
Done linting! Found 869 violations, 0 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure)?
    0.30.1

  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    Built from source

  • Paste your configuration file:
    base configuration

  • Are you using nested configurations?
    No

  • Which Xcode version are you using (check xcode-select -p)?
    10.1 (10B61)

  • Do you have a sample that shows the issue?
    Yes

// swiftlint:disable no_indentation_spaces this doesn't work as expected
func loggingFunctionTest(_ message: @autoclosure () -> String,
                         file: StaticString = #file,
                         function: StaticString = #function,
                         line: UInt = #line) {
// swiftlint:enable no_indentation_spaces
}

Full Output:
output.txt

@marcelofabri

This comment has been minimized.

Copy link
Collaborator

marcelofabri commented Feb 3, 2019

This is intentional as you can disable/enable several rules with the same command. It shouldn't warn several times for the same violation though.

See #2348.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.