realm / realm/SwiftLint

superfluous_disable_command warning displayed when disable opening_brace warning.

Open
#3,514 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

discussion enhancement
Dominant language
Swift
Stars
19.7k
Forks
2.3k
Avg merge
1d 1h
Merged PRs (30d)
11

Description

New Issue Checklist
Describe the bug

for this file, SwiftLint will warn line 3 for opening_brace rule.

if true ||
    false
{
    ...
}
$ swiftlint
Linting Swift files in current working directory
Linting 'test.swift' (1/1)
/tmp/work/test.swift:3:1: warning: Opening Brace Spacing Violation: Opening braces should be preceded by a single space and on the same line as the declaration. (opening_brace)
Done linting! Found 1 violation, 0 serious in 1 file.

So I added disable comment for it.

if true ||
    false
// swiftlint:disable:next opening_brace
{
    ...
}

then SwiftLint warn superfluous_disable_command instead.

$ swiftlint
Linting Swift files in current working directory
Linting 'test.swift' (1/1)
/tmp/work/test.swift:4:1: warning: Superfluous Disable Command Violation: SwiftLint rule 'opening_brace' did not trigger a violation in the disabled region. Please remove the disable command. (superfluous_disable_command)
Done linting! Found 1 violation, 0 serious in 1 file.
Complete output when running SwiftLint, including the stack trace and command used

already described in above.

Environment
  • SwiftLint version (run swiftlint version to be sure)? 0.42.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
  • Paste your configuration file: Nothing
  • Are you using nested configurations? No
  • Which Xcode version are you using (check xcodebuild -version)? 12.3
  • Do you have a sample that shows the issue? echo "if true ||\n false\n// swiftlint:disable:next opening_brace\n{\n ...\n}" | swiftlint

when fixing #3476, This superfluous_disable_command warning is correct.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported SwiftLint 0.42.0 behavior with the sample command in the issue. Trace how the opening_brace and superfluous_disable_command rules determine the disabled region and compare this case with the behavior addressed in #3476. Done means the interaction is handled consistently and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.