-
Notifications
You must be signed in to change notification settings - Fork 74
Description
To create a minimal example, I've created an otherwise-empty maven project, with palantir formatting configured via spotless:
<build>
<plugins>
<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>2.43.0</version>
<configuration>
<java>
<palantirJavaFormat>
<version>2.77.0</version>
</palantirJavaFormat>
</java>
</configuration>
</plugin>
</plugins>
</build>This is the java file I'm using to test. This matches the formatting applied by palantir formatter v2.77.0 (when invoked by either IntelliJ or Maven).
class Test {
public static void main(String[] args) {
String example =
"blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah";
}
}If I change the palantirJavaFormat -> version in the pom.xml to 2.78.0 and re-run mvn spotless:apply, there are still no formatting changes made to the java file.
However, if I format the file using the IntelliJ plugin with a version >= 2.78.0, the string is forcibly split out to a second line:
class Test {
public static void main(String[] args) {
String example =
"blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah"
+ " blah";
}
}It seems surprising to me that formatting the file would have different results when triggered via maven versus via the IntelliJ plugin. In principle, I'm not at all opposed to forcibly wrapping overly-long single-line strings, but it seems best to have consistent behavior between the IntelliJ plugin and the maven logic.
For example, this is troublesome if a project primarily uses the maven plugin to ensure formatting consistency, but my IntelliJ (with plugin version >= 2.78.0) is configured to automatically apply formatting to files I edit. In this scenario, any files I touch that have strings extending past column=120 are automatically reformatted, even if these strings are unrelated to the parts of the file that I'm editing. This is then likely to pollute commits with unrelated formatting changes.
This issue is made worse by the existence of #1451 , because some of the lines that the IntelliJ plugin is now choosing to split will immediately fail to match the maven-plugin's formatting expectations.
I believe this was introduced in #1419 , since that is the only non-"excavator" change between versions 2.77.0 and 2.78.0.