leading_whitespace
and trailing_newline
don't play nicely on empty files
#3854
Labels
enhancement
Ideas for improvements of existing features and rules.
New Issue Checklist
Describe the bug
trailing_newline
requires that a file ends with a single extra new-line character, even for empty files. Once this happens,leading_white
space gets violated, because (as far as it sees it), the file now starts with a redundant new line.To preempt the question of "Why do you have an empty file in the first place?": I just have a little empty playground I keep around in my project as a quick little scratch space, to use similar to the REPL, but with support for packages from my workspace.
Complete output when running SwiftLint, including the stack trace and command used
Then when you try to fix it:
$ swiftlint --fix Correcting Swift files in current working directory /path/dev playground.playground/Contents.swift:1:1 Corrected Leading Whitespace /path/dev playground.playground/Contents.swift:1:1 Corrected Trailing Newline
It actually hits a fixed point. Rerunning it over and over again doesn't cause any net changes to to the file.
Environment
0.46.2
Homebrew
xcodebuild -version
)?Xcode 13.2.1 Build version 13C100
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
.The text was updated successfully, but these errors were encountered: