PMD

PMD is a source code analyzer. It finds common programming flaws like unused variables, empty catch blocks, unnecessary object creation, and so forth.

https://pmd.github.io/

Enabling PMD

PMD can be run via command line interface, Ant task or Maven Plugin . Take a Maven project as an example, to enable PMD, first add following lines in your configuration:

build:
    environment:
        java: 'java-8-oracle'

    nodes:
        analysis:
            tests:
                override:
                    -
                        command: 'mvn pmd:pmd'
                        analysis:
                            file: 'path/to/pmd-result.xml' #path to analysis result of PMD
                            format: 'pmd-xml' #supported format by Scrutinizer

then configure PMD under the build element or reporting element in your pom.xml :

<project>

    ...
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-pmd-plugin</artifactId>
                <configuration>
                    <targetDirectory>target/pmd</targetDirectory>
                    <rulesets>
                        <ruleset>java-typeresolution</ruleset>
                        <ruleset>/rulesets/java/naming.xml</ruleset>
                        <ruleset>d:\rulesets\strings.xml</ruleset>
                        <ruleset>http://localhost/design.xml</ruleset>
                    </rulesets>
                </configuration>
            </plugin>
        </plugins>
    </build>
    ...

</project>