Skip to content
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

spotlessCheck sometimes fails even after running spotlessApply for googleJavaFormat #37

Closed
jaredjstewart opened this issue Oct 18, 2016 · 10 comments
Labels

Comments

@jaredjstewart
Copy link

Hi,

I want to add the spotless plugin pointed to the Eclipse Google Java Style Guide xml, but right now spotlessCheck fails for one file in my project even if I run it directly after spotlessApply. Is there any way to see what it thinks is wrong with the file?

Thank you!

@nedtwigg
Copy link
Member

That is very surprising. spotlessApply is how you see what is wrong with the file - spotlessCheck just checks that the file's content is the same as the end result of spotlessApply.

Can you copy-paste the file in question and/or the spotless part of your build.gradle?

@jaredjstewart
Copy link
Author

Branch with the spotless plugin added:
https://github.com/jaredjstewart/incubator-geode/tree/spotlessPluginGoogleStyle?files=1

From build.gradle:
apply plugin: "com.diffplug.gradle.spotless"

spotless {

java {

  //For now I've only set up formatting, not import ordering.

  //importOrder ['java', 'javax', 'org', 'com', 'com.diffplug', ''] //

An array of package names

  //importOrderFile 'spotless.importorder' // An import ordering file,

exported from Eclipse

  eclipseFormatFile

"${rootProject.projectDir}/etc/eclipse-java-google-style.xml"

}

}

On Oct 18, 2016 5:16 PM, "Ned Twigg" notifications@github.com wrote:

That is very surprising. spotlessApply is how you see what is wrong with
the file - spotlessCheck just checks that the file's content is the same
as the end result of spotlessApply.

Can you copy-paste the file in question and/or the spotless part of your
build.gradle?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#37 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AF8IKUC3MTwoCrye0njhgJsayo8f6og1ks5q1WF1gaJpZM4Kaa5o
.

@nedtwigg
Copy link
Member

nedtwigg commented Oct 19, 2016

I just duplicated your issue. You're using version 1.3.3, and upgrading to the latest 2.2.0 fixes the problem.

I'm not sure what went wrong, and I'm curious to find out, but there's been a lot of improvements since 1.3.3, so I'm not soo curious as to dig it up. But thanks for the report, and if you have any other issues in the future post another issue :)

Btw, if you want the "canonical" google style, and you don't care about the eclipse code formatter, you might want to take a look at this section of the readme.

@jaredjstewart
Copy link
Author

Fantastic, thank you so much!

@jaredjstewart
Copy link
Author

By the way, when I bumped to the latest version it worked with the Google Java Style eclipse XML. But when I tried switching to googleJavaStyle() I had the same issue (with different files) where spotlessCheck would fail directly after spotlessApply.

@nedtwigg
Copy link
Member

Thanks very much for letting me know, I'll dig in!

@nedtwigg nedtwigg reopened this Oct 20, 2016
@nedtwigg nedtwigg changed the title Any way to see what is wrong with the formatting of a particular file? spotlessCheck sometimes fails even after running spotlessApply for googleJavaFormat Oct 20, 2016
@nedtwigg nedtwigg added the bug label Oct 20, 2016
@nedtwigg
Copy link
Member

After a little digging, I've traced this to a bug in the google-java-format. I'm adding a feature to Spotless to handle misbehaving rules...

@jaredjstewart
Copy link
Author

Cool! By the way, the Apache Geode community started using Spotless to enforce code formatting as of this afternoon :)

@nedtwigg
Copy link
Member

nedtwigg commented Oct 27, 2016

Just wanted to let you know that I used your case of spotlessCheck fails right after calling spotlessApply to build a padded cell mode in spotless 2.3.0 which resolves exactly this kind of issue, and also generates a bug report for the rule in question.

I've filed a bug with google-java-format, so hopefully they'll be able to fix it in a future release.

Is it alright if I list apache-geode as an example project in the README?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants