SwiftLint icon indicating copy to clipboard operation
SwiftLint copied to clipboard

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

Open revolter opened this issue 5 years ago • 6 comments

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"
	}
}

revolter avatar Nov 14 '20 21:11 revolter

This issue has been automatically marked as stale because it has not had any recent activity. Please comment to prevent this issue from being closed. Thank you for your contributions!

stale[bot] avatar Jan 13 '21 21:01 stale[bot]

This is still valid.

revolter avatar Jan 24 '21 21:01 revolter

@jpsim, could you please reopen it?

revolter avatar Jan 24 '21 21:01 revolter

Sorry for the bot-thrash, reopened.

jpsim avatar Feb 24 '21 22:02 jpsim

The issue still exists. Any update or workaround?

OleksandrDrobyshev avatar Dec 09 '21 14:12 OleksandrDrobyshev

I worked on a fix for this, but I can't figure out the correct solution, and I also got busy with other stuff :(

revolter avatar Jan 15 '22 13:01 revolter