-
Notifications
You must be signed in to change notification settings - Fork 458
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
Align Java Eclipse formatter gradle interface with greclipse/scala #109
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @fvgh, just have a couple of comments, otherwise LGTM!
public void eclipseFormatFile(Object eclipseFormatFile) { | ||
eclipseFormatFile(EclipseFormatterStep.defaultVersion(), eclipseFormatFile); | ||
} | ||
|
||
/** Use {@link #eclipse(String)} instead */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be easier for a new user to understand if this said,
/** Use {@link #eclipse(String).configFile(String...)} instead. */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, 50/50, tie goes to the implementor :)
@@ -59,17 +63,23 @@ public void importOrderFile(Object importOrderFile) { | |||
addStep(ImportOrderStep.createFromFile(getProject().file(importOrderFile))); | |||
} | |||
|
|||
/** Use {@link #eclipse()} instead */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be easier for a new user to understand if this said,
/** Use {@link #eclipse().configFile(String...)} instead. */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would not be JavaDoc compliant. The comment is more fore the plugin developer. The user gets the "Use 'eclipse([version]).configFile()' instead." warning at the end of the build. Sounds reasonable to you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would not be JavaDoc compliant.
Oh yes, you're right! Silly me. 😉
I do understand that, from a Gradle user perspective, they'd write eclipse([version]).configFile configFile.xml
, but I still think that, from a spotless-lib user perspective, it should be clearly stated which method after eclipse()
needs to be invoked in the chain to get the exact same behaviour as eclipseFormatFile()
, so as to prevent confusion or ambiguity.
How about the following JavaDoc for eclipseFormatFile(String, Object)
...
/**
* Use {@link #eclipse(String) eclipse(String)}{@code .}{@link
* EclipseConfig#configFile(Object...) configFile(Object...)} instead.
*/
...and the following for eclipseFormatFile(Object)
instead?
/**
* Use {@link #eclipse() eclipse()}{@code .}{@link EclipseConfig#configFile(Object...)
* configFile(Object...)} instead.
*/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea itself is very nice and I will definitely use this approach in future when describing more complex use cases.
But honestly I do not think that this would fit here. I saw that you guys try avoid superfluous comments where code is self explaining. I think we agree that the usage of EclipseConfig
is quite self explaining.
But that's the final comment from my side. The final decision is yours. Let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, @nedtwigg, what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel it's 50/50 - tie goes to the implementor :)
@fvgh Although, having said in my review that things LGTM, it's not clear to me what you meant when you said,
Could you elaborate for me what you meant by checking the old |
Sorry for being that brief about
This is actually really something we need an agreement on, and I should have therefore be more explicit.
So all I did for testing is checking before I replaced |
I admit it's not clear to me how we'd even test that the deprecated interface is no longer used. Mocking? This is an area where I know very little. One one hand, I see this as a kind of refactoring, so if we don't get deprecation warnings at compile time, I'd be happy, On the other hand, @nedtwigg, do you have any thoughts on this? |
@jbduncan Sorry, I haven't explained it very well. No mocking is required. |
As you can see, |
This LGTM. This isn't anyone's fulltime job, so I think it's okay if we don't maintain tests for every deprecated feature. I'll leave it to @jbduncan to press the rebase and merge button if you feel your concerns are addressed well-enough. Totally fine to continue discussion too if they aren't :) |
@nedtwigg I am afraid I am already too tiered and should call it a day. I think I missed one of @jbduncan concerns which is the "deprecation policy". |
The upside - the deprecated functionality is being tested. The downside - there's a deprecated warning on compile. I see this as 50/50, implementation wins. |
I'm overall rather happy with this PR! As-is, I'd be happy to merge it in. My only concern left is whether the usage of @fvgh I think there's no need for an automated test for checking So I'll merge this in now. :) |
I think the standard industry policy is to mark deprecated methods as @deprecated, document the new usage, and emit a warning of some kind to prompt the user to update / maintain their usage. I think this PR checks all those boxes. Might be ways to improve on this though. Suggestions? |
Sounds good to me. 👍
I can only think of Guava's deprecation policy, but I don't think it's so applicable to Spotless because it involves a mixture of a custom |
Replaced importOrder array argument by varargs. Fixes #125.
To complete my open task as discussed.
I checked the old
eclipseFormatFile
manually before I modifiedspotlessSelf.gradle
. Let me know if you prefer an automated test.