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
vincentisambart opened this Issue Aug 30, 2017 · 6 comments

Comments

Projects
None yet
4 participants
@vincentisambart

vincentisambart commented Aug 30, 2017

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

This comment has been minimized.

Show comment
Hide comment
@BrandonZacharie

BrandonZacharie Aug 31, 2017

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

BrandonZacharie commented Aug 31, 2017

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

@marcelofabri

This comment has been minimized.

Show comment
Hide comment
@marcelofabri

marcelofabri Sep 3, 2017

Collaborator

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

Collaborator

marcelofabri commented Sep 3, 2017

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

@vincentisambart

This comment has been minimized.

Show comment
Hide comment
@vincentisambart

vincentisambart Sep 4, 2017

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)

vincentisambart commented Sep 4, 2017

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

This comment has been minimized.

Show comment
Hide comment
@danj-stripe

danj-stripe Sep 6, 2017

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?

danj-stripe commented Sep 6, 2017

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

This comment has been minimized.

Show comment
Hide comment
@marcelofabri

marcelofabri Sep 6, 2017

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.

Collaborator

marcelofabri commented Sep 6, 2017

@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

This comment has been minimized.

Show comment
Hide comment
@danj-stripe

danj-stripe Sep 6, 2017

Of course, my mistake!

danj-stripe commented Sep 6, 2017

Of course, my mistake!

marcelofabri added a commit to marcelofabri/SwiftLint that referenced this issue Sep 11, 2017

marcelofabri added a commit to marcelofabri/SwiftLint that referenced this issue Sep 14, 2017

marcelofabri added a commit to marcelofabri/SwiftLint that referenced this issue Sep 30, 2017

sirlantis added a commit to sirlantis/SwiftLint that referenced this issue Oct 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment