$ 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.
swiftlint version to be sure)?opt_in_rules:
- file_header
xcode-select -p)?// 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.
I'm getting the same thing. This was working in 0.21.0
I've opened #1816 that should fix the issue. It'd be awesome if some of you could try it.
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)
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 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.
Of course, my mistake!
Most helpful comment
I'm getting the same thing. This was working in 0.21.0