-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't fail after first codestyle violation #287
Comments
This would probably be a helpful feature. Formatting failures can be split into two categories:
Spotless focuses heavily on the first category, because they're "free" from a developer effort standpoint. Issues that can't be fixed automatically require some amount of developer attention, which may or may not be worth it to any given project. That said, there are a lot of formatters out there that require user intervention, and there are users who want that. This is the code that applies the steps, where the error is thrown and passed to the format exception policy: spotless/lib/src/main/java/com/diffplug/spotless/Formatter.java Lines 219 to 245 in 366c1b9
This is the formatter exception policy used by the gradle plugin, which rethrows the error as runtime exception and stops the formatting: spotless/lib/src/main/java/com/diffplug/spotless/FormatExceptionPolicyStrict.java Lines 42 to 57 in 366c1b9
To make the change you're suggesting, here is how I would go about it:
Btw, there is an open bug related to this at #194. It might be a good idea to start by understanding and fixing that bug. |
Also, Gradle has the |
Sorry for the late response. Was busy on other projects. @JLLeitschuh This is exactly what I needed and seems to be already the solution. I switched over to ktlint-gradle anyway as I mainly intended to use spotless for the ktlint checks and with ktlint-gradle your suggestion works perfectly fine. I will try out this suggestion for spotless as well next week, just to ensure that we have a proper outcome of this issue. |
This comment made me chuckle as I'm a maintainer on both projects. Also, if this issue is truly resolved for you, please close the issue when you've confirmed it's fixed. |
@JLLeitschuh Haha, yeah, I saw that. ;) The main reason for switching to ktlint-gradle is that I like to keep the toolchain as lean as possible and we really only want the checks in ktlint for now. No other reasons at the moment. :) I will make sure to close the issue after confirming that |
So I check on a project with two different violations in two different files. Unfortunately So I have to keep the issue open. |
Hi, |
The reason that That's just a guess though. The root cause may not be that. |
Any found a workaround for this? |
sorry for getting here one year later |
It is blocked on #1097. |
Just to add to this I run into a similar issue with only reporting the first style violation when using a multiple subproject build. When I run
Then I run ':sub-module-1:spotlessApply' and it fixes a load of files then when I run
I have the following in my root gradle
For context I am trying to apply spotless to my entire codebase for the first time |
This is fixed in |
I tried out spotless today for the first time on one of our Kotlin projects and thus used the ktlint plugin.
It seems to work quite well so far, however
spotlessCheck
always fails right after finding the first codestyle violation whilektlint
(when directly run on the codebase) lists all violations in a neat list.I also tried to apply various different ktlint reporters (like the checkstyle one), but the result always seems to be the same - failure after the first violation (and in this case also no checkstyle XML is generated).
Long story short: can I force spotless (or the ktlint plugin, if that's the culprit) to continue its checks after it found a violation so that I can see all violations at a glance (and if possible without that stacktrace which causes the need for a lot of scrolling to find the error)?
Config looks like this:
Sample output:
The text was updated successfully, but these errors were encountered: