-
Notifications
You must be signed in to change notification settings - Fork 570
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
DRAFT: switch to spotless #1460
base: main
Are you sure you want to change the base?
DRAFT: switch to spotless #1460
Conversation
there were some files using spaces while others were using tabs ...
Thanks for your pull request! This pull request does not follow the contribution rules. Could you have a look? ❌ All commit messages should start with a JIRA issue key matching pattern › This message was automatically generated. |
@@ -14,69 +14,24 @@ | |||
|
|||
<module name="TreeWalker"> | |||
|
|||
<!-- cannot do with spotless but then is it really needed ? --> | |||
<module name="RegexpSinglelineJava"> | |||
<!-- do not allow a package declaration that contains ".target." or "target;" --> | |||
<property name="format" value="^package .*\.target[\.;]"/> | |||
<property name="message" value="Do not use "target" as package name element"/> | |||
</module> | |||
|
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.
And here's the checkstyle config ...
@yrodiere I'll let you have a look at this one (probably whenever you have nothing interesting to look into 😄 ) |
Looks like we'd be better off keeping license header checks in checkstyle?
Annoying indeed... though it's quite rare that we include comments in docs code snippets, at least for Hibernate Search, so I suppose we can live with it.
Will have a look, but if we need checkstyle for license header checks anyway, I suppose it's no big deal. |
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. |
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.
Can you create an issue to ultimately switch to SPDX headers, like in Search/ORM?
@@ -1,3 +1,4 @@ | |||
<?xml version="1.0" encoding="utf-8" ?> |
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.
Oh, so it's not limited to code, it also gets applied to poms. Nice.
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.
There's also this "pom" section that can be configured: https://github.com/diffplug/spotless/tree/main/plugin-maven#maven-pom where it can keep the pom "formatted" too, but I didn't want to try it as we have some cases where the profile has to go last (those reporting modules etc....) so I thought better leave it as is 😃
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.
Ah, so this one was manual. Gotcha.
You're right, it's probably safer to skip poms, I didn't think of that.
<executions> | ||
<execution> | ||
<id>import-sorting</id> | ||
<goals> | ||
<goal>${goal.impsort-maven-plugin}</goal> | ||
</goals> | ||
<phase>process-sources</phase> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>net.revelc.code.formatter</groupId> | ||
<artifactId>formatter-maven-plugin</artifactId> | ||
<version>${version.formatter-maven-plugin}</version> |
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.
So we can replace both of these plugins with just spotless? That's already a nice improvement, no?
|
||
<importOrder> | ||
<!-- you can use an empty string for all the imports you didn't specify explicitly, '|' to join group without blank line, and '\#` prefix for static imports. --> | ||
<order>\#,java,javax,jakarta,org.openjdk.jmh,org.hibernate,org.hibernate.testing,org.hibernate.test,org.junit,org.jboss,com,javafx.beans,</order> |
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.
Can this be imported from a file? People will need a file specifying import orders in order to set up formatting in their IDE.
Unless spotless gets executed automatically in the IDE, but I suspect it only is when compiling...
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.
yes there's an option to pass a file:
<order>java|javax,org,com,com.diffplug,,\#com.diffplug,\#</order> <!-- or use <file>${project.basedir}/eclipse.importorder</file> -->
<!-- default one fails to process the classes --> | ||
<engine>cleanthat-javaparser-unnecessaryimport</engine> | ||
</removeUnusedImports> | ||
<licenseHeader> |
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.
Does this apply the header automatically, on top of just checking?
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.
it's like with those other plugins, if spotless:apply
is executed then the headers are added, and if it's spotless:check
then it fails the build if the header is missing...
<artifactId>impsort-maven-plugin</artifactId> | ||
<version>${version.impsort-maven-plugin}</version> | ||
<groupId>com.diffplug.spotless</groupId> | ||
<artifactId>spotless-maven-plugin</artifactId> |
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.
We probably need two execution mode: one for dev (auto formats) and one for CI (checks only, no auto format)
This one is only to evaluate the option and not actually to apply the change ...
I thought that it would be better to test this on the Validator as it uses all 3 plugins and has a smaller codebase.
Best to look by commit (if looked at all 😅).
(this work is not complete: the maven properties and builds should also be updated to make it all work and I haven't done that here yet...)
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on licensing, please check here.