Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/blundell/createyourowncheckstylecheck

How to write a custom CheckStyle check and incorporate it into your Maven project
https://github.com/blundell/createyourowncheckstylecheck

Last synced: about 2 months ago
JSON representation

How to write a custom CheckStyle check and incorporate it into your Maven project

Awesome Lists containing this project

README

        

CreateYourOwnCheckStyleCheck
============================

Contains two projects

- **TestProject** contains the poorly written Java code that will have checkstyle ran on it

- **BlundellCheckstyle** contains the custom checkstyle checks that have been written

How it works

- **TestProject** uses the maven-checkstyle-plugin
- the maven-checkstyle-plugin has a dependency on **BlundellCheckStyle**
- **BlundellCheckstyle** is where we create the custom checks
- the maven-checkstyle-plugin then uses a *checkstyle-configuration.xml* file to declare what checks we want checkstyle to run
- within checkstyle-configuration.xml we declare our custom checks from **BlundellCheckStyle**

How to run checkstyle

- from a Terminal
- run mvn install
- go into the TestProject folder
- run mvn checkstyle:checkstyle
- open up target/site/checkstyle.html to see style errors

Current Limitations

- in *checkstyle-configuration.xml* we have to use the full package of the check *com.blundell.checks.AntiHungarian*
- this can be fixed by declaring a *checkstyle-packages.xml* **this currently doesn't work**

*checkstyle-packages.xml* would looks something like this:

```xml

```

and you would add it to the maven-checkstyle-plugin declaration

// There are multiple ways to try this, I haven't found one that works
// so I do not want to document it here

then your checkstyle-configuration.xml would not need the package:

```xml




```