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 Violation buggy #1810

Closed
2 tasks done
vincentisambart opened this issue Aug 30, 2017 · 6 comments
Closed
2 tasks done

Superfluous Disable Command Violation buggy #1810

vincentisambart opened this issue Aug 30, 2017 · 6 comments
Labels
bug Unexpected and reproducible misbehavior.

Comments

@vincentisambart
Copy link

New Issue Checklist

Bug Report

Complete output when running SwiftLint, including the stack trace and command used
$ swiftlint lint
Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'foo.swift' (1/1)
~/test-swiftlint/foo.swift:1:33: error: Superfluous Disable Command Violation: SwiftLint rule 'file_header' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
Done linting! Found 1 violation, 1 serious in 1 file.

Environment

  • SwiftLint version (run swiftlint version to be sure)?
    • 0.22.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)?
    • Homebrew
  • Paste your configuration file:
opt_in_rules:
  - file_header
  • Are you using nested configurations?
    • No
  • Which Xcode version are you using (check xcode-select -p)?
    • Xcode 8.3.3
  • Do you have a sample that shows the issue?
// swiftlint:disable file_header
// Copyright 2017 XXXXXX

If I remove the line with the disable command as told I do get a warning, meaning that the disable was not superfluous:

$ swiftlint lint
Loading configuration from '.swiftlint.yml'
Linting Swift files in current working directory
Linting 'foo.swift' (1/1)
~/test-swiftlint/foo.swift:1:4: warning: File Header Violation: Header comments should be consistent with project patterns. (file_header)
Done linting! Found 1 violation, 0 serious in 1 file.
@BrandonZacharie
Copy link

BrandonZacharie commented Aug 31, 2017

I'm getting the same thing. This was working in 0.21.0

@marcelofabri marcelofabri added the bug Unexpected and reproducible misbehavior. label Aug 31, 2017
@marcelofabri
Copy link
Collaborator

I've opened #1816 that should fix the issue. It'd be awesome if some of you could try it.

@vincentisambart
Copy link
Author

I managed to compile #1816 and the incorrect error is indeed not displayed anymore.

However, to compile #1816 I had to modify the Yams projects (in Carthage/Checkouts/Yams and Carthage/Checkouts/SourceKitten/Carthage/Checkouts/Yams) to not run swiftlint because with SwiftLint 0.22 installed, an error stopped the build:

SwiftLint/Carthage/Checkouts/Yams/Sources/Yams/Node.swift:271: error: Superfluous Disable Command Violation: SwiftLint rule 'file_length' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)

@danj-stripe
Copy link

Thanks for looking at this! It appears to be working for our project.

I noticed that the swiftlint:disable command needs to come before the file header comment. If the file header comment comes first, and you put // swiftlint:disable file_header at the end, I'm getting violations for both file_header and superfluous_disable_command, which is unexpected.

Does disable only work when it's at the beginning of the file?

@marcelofabri
Copy link
Collaborator

@danj-stripe You're right, // swiftlint:disable <id> disables that rule until an // swiftlint:enable <id> is found (or the file ends). You can use // swiftlint:disable:previous to disable a previous violation.

@danj-stripe
Copy link

Of course, my mistake!

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