-
Notifications
You must be signed in to change notification settings - Fork 461
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
ignoreErrorForPath does not work, perhaps related to build folder #194
Comments
Can you copy-paste the stacktrace of the error? |
Sorry, I wasn't quite clear in my original post. There are no exceptions thrown, but the file that should be ignored still triggers a build failure because of formatting issues. Edit: This is where I'm looking for information: link |
This are my ignore statements: ignoreErrorForPath 'build/generated/source/proto/test/java/de/javakaffee/kryoserializers/protobuf/SampleProtoAOuterClass.java'
ignoreErrorForPath 'build/generated/source/proto/test/java/de/javakaffee/kryoserializers/protobuf/SampleProtoBOuterClass.java'
ignoreErrorForPath 'build\\generated\\source\\proto\\test\\java\\de\\javakaffee\\kryoserializers\\protobuf\\SampleProtoAOuterClass.java'
ignoreErrorForPath 'build\\generated\\source\\proto\\test\\java\\de\\javakaffee\\kryoserializers\\protobuf\\SampleProtoBOuterClass.java' |
Run |
It's a standard format violation exception.
|
Can you copy paste your full spotless config? I wonder if the ignores are in the wrong place, e.g. in a different format? |
Here's the commit! I disabled the Just the
The |
Well this is a very strange bug indeed :) I took a look at the code, and it turns out I'm probably wrong about unix-style relative paths, looks like you do need both the One workaround you could do is set the target of java manually: java {
target 'src/main/**/*.java' But even if that workaround fixes it, we should do the following:
This isn't gonna make the top of my todo list anytime soon, but it might eventually :) PR's welcome. |
I have the same issue.
The error message when invoked
|
Welp, that's a strike against the "build folder" theory. I'm baffled :) Thanks for the extra evidence! If any other users have evidence to contribute, please do! Best of all would be an opensource repo that reproduces the issue. |
This does not seem to be a bug but a misconception on what @nedtwigg is this assessment correct? If so, could the |
@thc202 I believe those exceptions are thrown by the formatters when they detect a format violation (or perhaps that was a legacy system and now more precise return values are used). |
I don't understand that from taking a look at the history, it seems that the |
@thc202 You're correct, it appears that formatters currently are intended to throw exceptions under 'exceptional' circumstances, rather than formatting exceptions, and that the check for path inclusion only occurs during an exception. The legacy code that relies on exceptions is located here. @nedtwigg Can you confirm our hypotheses? Should the path check occur for non-erroring steps as well and just return the original String? |
Bump :) |
Thanks very much for this issue, @thc202 and @Magneticflux.
You are correct, and this misconception is so deep that I didn't realize you were right until I finally sat down to try to actually fix the bug. I considered attempting to resolve this by making I think this whole issue is actually a symptom of our users didn't have an easy way to exclude a file from formatting. We told people "if you want to ignore a folder, set target to be everything except that one file". But that would be quite onerous for the examples given in this issue. I'm attempting to resolve this by adding a If you've got a file that you'd like to be formatted, but for whatever reason it sometimes causes the third-party formatter to throw exceptions and you don't want them to block your build then use |
Published in 3.18.0. |
I have supplied a path
src/main/org/x/y/z/ExcludedFile.java
to theignoreErrorForPath
method and the file still causes the build to fail. I've tried both Unix and Windows style paths.Spotless 3.8.0
Gradle 4.5
Eclipse formatter
The text was updated successfully, but these errors were encountered: