A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://maven.apache.org/plugins/maven-pmd-plugin/examples/javascriptReport.html below:

Analyzing JavaScript Code – Apache Maven PMD Plugin

Analyzing JavaScript Code

The PMD plugin analyzes Java by default. You can configure it to analyze JavaScript files instead as shown below.

The example assumes that the JavaScript source code is stored in the subdirectory src/main/javascript and enables all rules from the "Best Practices", "Codestyle", and "Error Prone" categories.

Note that you have to make sure that you configure compileSourceRoots and includes, so that PMD finds the JavaScript files.

See JavaScript Rule Index for the list of available rules.

<project>
  ...
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>3.27.0</version>
        <configuration>
          <language>javascript</language>
          <rulesets>
            <ruleset>/category/ecmascript/bestpractices.xml</ruleset>
            <ruleset>/category/ecmascript/codestyle.xml</ruleset>
            <ruleset>/category/ecmascript/errorprone.xml</ruleset>
          </rulesets>
          <includes>
            <include>**/*.js</include>
          </includes>
          <compileSourceRoots>
            <compileSourceRoot>${basedir}/src/main/javascript</compileSourceRoot>
          </compileSourceRoots>
        </configuration>
        <reportSets>
          <reportSet>
            <reports>
              <report>pmd</report>
            </reports>
          </reportSet>
        </reportSets>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

Note: Configuring compileSourceRoots only works with Maven 3.3.9 and later. For older versions, you'll need to use build-helper-maven-plugin with the add-source goal in order to add the additional source directories, so that PMD finds the JavaScript files.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4