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 · 4 comments
Labels
bug Unexpected and reproducible misbehavior.

Comments

@mbarthelemy
Copy link

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
Copy link
Collaborator

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.

@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Feb 3, 2019
sjavora pushed a commit to sjavora/SwiftLint that referenced this issue Mar 9, 2019
@Megal
Copy link

Megal commented Apr 10, 2019

We're migrating from 0.26 version. We have a lot of comments why we disable some rules in code. For example:

swiftlint:disable file_length Big class by design. Business logic is too sophisticated.

What options do we have to keep annotations on disabled rules?

@marcelofabri
Copy link
Collaborator

We're migrating from 0.26 version. We have a lot of comments why we disable some rules in code. For example:

swiftlint:disable file_length Big class by design. Business logic is too sophisticated.

What options do we have to keep annotations on disabled rules?

You can move the comment to a new line before or after the disable command.

@kevinrandrup
Copy link
Contributor

Would a PR adding a delimiter be considered / possible? " - " comes to mind as a way to express "this is now documentation, not a new rule"

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

4 participants