Open ladislas opened 10 months ago
funny thing is that using swiftlint --strict
, doesn't change all the warnings to errors, I only see the two errors I already have with swiftlint
alone
Linting and fixing are two different modes. With --fix
, SwiftLint only reports corrected violations. They don't fail. That said, --strict
doesn't have any effect when auto-correcting code.
For which rules specifically does no promotion happen when running swiftlint --strict
?
Example:
Modify 2 files:
#1
, which is correctable.#2
, which isn't correctable.Run:
swiftlint lint --fix --strict
Behavior:
swiftlint
exists with non-0 code.If you run the same command again, however, B isn't reported, and swiftlint
exists with a 0 code, despite the fact that there's a linting issue.
I believe this may be what @ladislas was pointing out.
--fix
fixes what's fixable. Nothing else is reported. Thus, --strict
doesn't have an effect.
A check could be added that warns about --strict
not having any effect if it comes piggyback with --fix
.
swiftlint
exists with non-0 code.
I cannot see that. swiftlint --fix [--strict]
always finishes with 0.
I'll keep this open awaiting your feedback.
I believe this may be what @ladislas was pointing out.
@JaviSoto yes exactly! thanks for clarifying :)
--fix fixes what's fixable. Nothing else is reported. Thus, --strict doesn't have an effect.
@SimplyDanny that makes it clear!
any reason why they don't work together?
A check could be added that warns about
--strict
not having any effect if it comes piggyback with--fix
.
This is nice so at least the user knows this is going on, but it's still undesireable behavior: if you're using --strict
it's because you want it to fail if it has any issues. Using --fix
should mean "fix anything you can", but given that a lot of the rules can't be fixed, it shouldn't just swallow errors. Because of this behavior we're having to run Swiftlint twice, once with --fix
and one without, which is very slow in our codebase. We'd like to be able to run it just once and have it fail if there are any outstanding issues
I get the confusion now. With --fix
being an option of lint
, people expect the normal lint
behavior with automatic fixes for correctable rules on top. This would be different if fix
was its own command and not an option of lint
.
Without a new option, this would be a breaking change, though.
New Issue Checklist
Describe the bug
We are using swiftlint with pre-commit with the command provided in the documentation
It does fix the issues but it does not fail.
changing to just
swiftlint
fails as expected but doesn't fix the issuesComplete output when running SwiftLint, including the stack trace and command used
with
swiftlint --fix --strict
just with
swiftlint
Environment
swiftlint version
to be sure)?Homebrew
no
xcodebuild -version
)?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 useswiftlint lint --path [file here] --no-cache --enable-all-rules
.It involves using pre-commit, so no