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:apply for Java does not format unused imports correctly #402

Closed
FlorianZipser opened this issue May 23, 2019 · 3 comments
Closed
Labels

Comments

@FlorianZipser
Copy link

FlorianZipser commented May 23, 2019

When formatting unused imports in Java code with spotless plugin for maven, the imports are removed, but unnecessary lines remain.

Apache Maven 3.6.0
spotless version 1.23

For instance using spotless:apply to the following code

package foo;

import unused

public class Foo{
}

will produce

package foo;


public class Foo{
}

Includeing two linebreaks. This causes spotless:check to fail.

@nedtwigg
Copy link
Member

Can you copy-paste your spotless configuration block?

@nedtwigg nedtwigg added the bug label May 23, 2019
@FlorianZipser
Copy link
Author

FlorianZipser commented May 24, 2019

Sure, sorry for the delay:

			<plugin>
				<!-- checks code format -->
				<groupId>com.diffplug.spotless</groupId>
				<artifactId>spotless-maven-plugin</artifactId>
				<version>${spotless.version}</version>
				<executions>
					<execution>
						<phase>verify</phase>
						<goals>
							<goal>check</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<java>
						<googleJavaFormat>
							<version>${google-java-format.version}</version>
							<style>GOOGLE</style>
						</googleJavaFormat>
						<removeUnusedImports />
					</java>
				</configuration>
			</plugin>

@nedtwigg
Copy link
Member

nedtwigg commented May 6, 2020

As of maven-plugin 1.31.0, paddedcell is always enabled, which would fix this problem. Fixed by #565

@nedtwigg nedtwigg closed this as completed May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants