spoon
spoon copied to clipboard
Spotless for imports
Currently, our import ordering in spoon is a bit messy. This leads to an unpleasant time with IntelliJ trying to sort the imports in a more normal order. Why don't we use spotless-maven-plugin to sort all our imports in a fixed sorting? This also helps to reduce diffs in the future for PRs. The benefit compared to checkstyle is that we can do the sorting automatic. See https://github.com/diffplug/spotless/tree/main/plugin-maven#java for an example.
We need to add
<java>
<importOrder />
</java>
Any wishes for the order?
<order>java|javax,org,com,com.diffplug,,\#com.diffplug,\#</order>
<semanticSort>false</semanticSort>
<wildcardsLast>false</wildcardsLast>
I don't care as long as IJ can follow the same order and I don't need to run spotless :^)
Can we please add a good-first-issue label here? We can then ask new contributors to work on this :)
done
Hello, I would like to try to contribute on this issue.
I noticed that Spotless is applied to the files included in src/test/java/spoon/testing/assertions/**/*.java
. I plan to accept all the Java files excepted the resources (example: **/resources/**
). But, there will be a lot of changes due to the initial Plantir format usage on src/test/java/spoon/testing/assertions/**/*.java
(around 1550 Java files impacted). May I remove this particular format?
I suggest also to add <removeUnusedImports />
. There are 29 files impacted.
By using only <importOrder />
, there are 735 files impacted.
I guess it is better to do a PR only about the pom.xml
change and another one about the spotless:apply
.
Hi @micka-lama ! We would want to be similar to IJ style guide. @I-Al-Istannen do you use the formatted in IJ with default configurations? We could then configure spotless accordingly.
Yea, just the defaults (except forbidding star imports). static imports are split and placed after the normal imports:
non-static
<blank>
static javax
static java
<blank>
static *
@micka-lama we look forward to your PR that configures spotless following two rules:
- Sticking to IJ style guide.
- Configure the style guide for imports like @I-Al-Istannen said. You can also include configuration for IntelliJ workspace so that they don't contradict with spotless.