PMD is a parser for the Java language. You may use PMD in embedded mode or else pass your PMD reports to Themis.

Embedded analysis in Themis

To devolve to Themis the analysis of your Java code to PMD, you should configure first the embedded linters mode for your source. You may then add a sub-plugin for PMD.

The execution of PMD is set by a whole rulesets, each defining a whole rules to observe on analysis. Here is an exemple of catalogue of rulesets.

Themis use the whole existing rules for Java thanks to the global ruleset: ruletsets/internal/all-java.xml.

You may modify that configuration by indicating a listing of rulesets separated by commas (,). 

Example: rulesets/java/unusedcode.xml,rulesets/java/basic.xml

Informations and installed versions


Extensions of analyzed files: .java.

Version of Themis Version of PMD
2.6.0 6.9.0
1.0.4 5.5.3


Mailing of PMD reports to Themis

If you use PMD outside Themis, you have the possibility to synchronize the reports produced by PMD at the XML format to Themis.

Preparation of the source in Themis

The produced PMD reports are tied to one of your code repositories. You have to inform your Themis source of the data linked to the code coverage will come from external reports. 

To this end, seek in the Administration part, then Projects and identify the concerned Source. Add then a plugin for the "Technical debt" practice, by indicating External reports - PMD. As a reminder, the addition of a plugin takes place in opening the listing of the plugins of the source, then by clicking on Adding a plugin.

Use of the Jenkins plugin

In Jenkins, add a step in the Actions following the build part, by clicking on the drop-down Add and action after the build. Select Send report files to Themis.

On adding this step, the XML report produced by PMD has to be available in the work directory of Jenkins. You have therefore already performed PMD on adding this step in your workflow.

Select the body of Themis and indicate the key of the source tied to the code repository ongoing analysis in Jenkins.

In the Report Files section, select for Type the PMD value. Then in Path, indicate one or several expressions (separated by commas) allowing to access to the XML files produced by PMD. For example, pmd.xml or **/target/**/pmd.xml

Mailing of files by the REST API

If you do not use Jenkins, or do not wish to use the Jenkins plugin, it is possible to use the API of Themis to synchronize the PMD reports. Here is an example of BASH script that you may implement in an other language if you wish (the variables at first are to tailor to your context).

Note that the type of reports to specify is pmd in the payload of the request. 


#TOCHANGE THEMIS_URL="" SOURCE_KEY="da4e11f4-5489-4b2a-a028-20d071b1c671" API_KEY="NWJjZWQ3ZmNhYTJhYzkwMWRmNGZhYTYx" PMD_REPORT_FILE="pmd.xml" CURRENT_COMMIT=$(git rev-parse HEAD) #Current GIT commit
#For SVN : $(svn info --show-item last-changed-revision) CURRENT_DATE=$(date +%s)"000" WORKSPACE=$(pwd) #the root directory of the source code repository REPORT_ARCHIVE="" #First of all, create a directory with all PMD reports REPORT_DIR=$(mktemp -d -p /tmp) find . -name $PMD_REPORT_FILE -exec cp --parents \{\} $REPORT_DIR \; if [ -e $REPORT_ARCHIVE ];then echo "Remove existing archive" rm $REPORT_ARCHIVE else echo "File "$REPORT_ARCHIVE" does not exist" fi #Create archive to send to Themis zip -r $REPORT_ARCHIVE $REPORT_DIR curl -i \ -H "Content-Type: multipart/form-data" \ -H "Accept: application/json,application/zip" \ -H "themis-api-key:$API_KEY" \ -X POST \ -F 'metadata={ "executionDate" : "'$CURRENT_DATE'", "dataType" : "pmd", "commit" : "'$CURRENT_COMMIT'", "dataWorkspace" : "'$WORKSPACE'"};type=application/json' \ -F "archive=@"$REPORT_ARCHIVE";type=application/zip" \ $THEMIS_URL/api/reportFiles/$SOURCE_KEY rm -rf $REPORT_DIR
Was this article helpful?
0 out of 0 found this helpful



Please sign in to leave a comment.