Skip to content

ArneLimburg/checkstyle-formatter-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

maintained Maven Central build

Checkstyle Formatter Maven Plugin

This is a maven plugin to format code with checkstyle rules.

Features

Currently the following rules are formatted automatically:

Configuration

The plugin is configured like the checkstyle plugin (from which it is derived). See in their documentation for configuration options: Maven Checkstyle Plugin. There is one more configuration option: You can configure, which new line character will be chosen when writing the files. You can do this with the checkstyleFormatter.lineEndingproperty.

Reporting a bug

When you report a bug, please come up with a pull-request that demonstrates the bug with a failing test:

  1. Create a source tree in src/it/java with the code that is not formatted correctly and another source tree with the code with the expected formatting result.

  2. Create a test that references your source tree:

import org.junit.Rule;
import org.junit.Test;

import dev.limburg.checkstyle.CheckstyleFormatterRule;

public class YourTest {

    @Rule
    public CheckstyleFormatterRule rule = new CheckstyleFormatterRule();

    @Test
    public void formatFinalParameter() throws Exception {
        rule.given("src/it/java/your/source/tree/with/the/failing/code");
        rule.whenExecuteFormatting();
        rule.thenResultIsSameAs("src/it/java/your/source/tree/with/the/expected/result");
    }
}

The created test should fail. This demonstrates the bug.

Contributing

We always implement formatters test-driven. So when you want to contribute a formatter, please first create a failing test like described in "Reporting a bug". Then implement your formatter by implementing the interface LineFormatter and register it in the class FileFormatter with the corresponding key of the formatted checkstyle rule.

About

A maven plugin to format code with checkstyle rules

Resources

License

Stars

4 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors

Languages