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

Spotless maven plugin sometimes doesn't detect wrong java Eclipse formatting #2066

Open
pbite opened this issue Mar 16, 2024 · 0 comments
Open

Comments

@pbite
Copy link

pbite commented Mar 16, 2024

Hi,

We use maven spotless plugin for java formatting in Eclipse format. In some cases it seems spotless:check doesn't shows errors on wrong formatting and spotless:apply doesn't apply changes.

Spotless maven plugin version: 2.43.0.
Maven version: 3.8.4
OS: Windows 10 Enterprise, 22H2
Spotless configuration:

<plugin>
  <groupId>com.diffplug.spotless</groupId>
  <artifactId>spotless-maven-plugin</artifactId>
  <version>${com.diffplug.spotless.plugin.version}</version>
  <configuration>
    <java>
      <eclipse></eclipse> <!-- we use formatting from the file, but same issue is with default Eclipse formatting -->
      <importOrder>
        <order>java,javax,org,com</order>
      </importOrder>
      <removeUnusedImports/>
    </java>
  </configuration>
</plugin>

Simplified java class when formatting is not applied (here are doubled empty lines that are not allowed):

package com.myproject;

import static org.mockito.Mockito.when;

class SpotlessTest {

	void test() {

		when(null);

		
		
	}
}

It seems that issue is somehow related to when, because on code below formatting is applied:

package com.myproject;

import static org.mockito.Mockito.when;

class SpotlessTest {

	void test() {

		String a = "a";
		when(null);

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

No branches or pull requests

1 participant