realm / realm/SwiftLint

`indentation_width` triggered when the previous line is commented at the beginning

Open
#3,430 6 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Commenting a line at the beginning of it incorrectly triggers indentation_width for the next line.

Side note: This is how Xcode comments lines by default when using cmd + /.

Complete output when running SwiftLint, including the stack trace and command used
$ ./swiftlint lint --path Test.swift
Loading configuration from '.swiftlint.yml'
Linting Swift files at paths Test.swift
Linting 'Test.swift' (1/1)
/Users/revolt/Downloads/portable_swiftlint/Test.swift:4:1: warning: Indentation Width Violation: Code should be indented using one tab or 4 spaces. (indentation_width)
Done linting! Found 1 violation, 0 serious in 1 file.
Environment
  • SwiftLint version (run swiftlint version to be sure)? 0.41.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Using a pre-built package
  • Paste your configuration file:
opt_in_rules:
    - indentation_width
  • Are you using nested configurations? No
    If so, paste their relative paths and respective contents.
  • Which Xcode version are you using (check xcodebuild -version)? Xcode 12.2 Build version 12B45b
  • Do you have a sample that shows the issue? Run echo "[string here]" | swiftlint lint --no-cache --use-stdin --enable-all-rules
    to quickly test if your example is really demonstrating the issue. If your example is more
    complex, you can use swiftlint lint --path [file here] --no-cache --enable-all-rules.
class Test {
	func test() {
//		comment
		let string = "string"
	}
}

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

Reproduce the report with the Swift sample in Test.swift, the opt_in_rules entry in .swiftlint.yml, and the command shown in the issue. Start by locating the implementation or entry point for the indentation_width rule; done means the commented previous line no longer causes a violation for the following line, with the behavior verified through SwiftLint linting.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.