Pmd plugin¶
Description¶
The pmd plugin is used for executing the pmd static code analyzer tool suite.
Mandatory settings¶
There are no mandatory settings for this plugin.
Optional settings¶
The configuration of the pmd plugin may contain the following settings:
-
patterns
A list of patterns to apply on the command line. See Patterns (5).
-
enviroment
A list of environment variables that should be set before the commands are executed. See Environment (5).
-
command-line
Additional command line parameters to pass as a list of separate arguments. By default no additional arguments are added.
-
working-dir
The working directory of the command. Can be an absolute path are a relative one w.r.t. the path to the considered configuration file. Commands that should be executed relative to the current working dir can use the
{EH_WORKING_DIR}
pattern.
-
exec
The path to the pmd-run executable. The path can either be an absolute path or a relative path from the current working directory. Default:
pmd
.
-
tool
-
The pmd tool to use. The currently supported tools are:
- cpd
Default:
cpd
-
language
Specify the language PMD is analyzing. Check the
--language
option of the pmd documentation for more information. Default: no explicit language parameter is passed.
Cpd specific settings¶
-
minimum-tokens
The minimum token length to be considered a duplicate. Check the
--minimum-tokens
option of the cpd documentation for more information. Default: no explicit minimum tokens parameter is passed.
-
files
A list of files to check for duplicated code. Check the
--files
option of the cpd documentation for more information. Default: no explicit files parameter is passed.
Example¶
Configuration¶
commands: # Define the commands that can be run
example: Run the pmd example
patterns: # Define the patterns that can be used
TARGET: # Define targets to check
default-values: # Only define the default value
- hello
- world
example:
- pmd # Use the cppcheck plugin when running the 'example' command
pmd: # Cppcheck configuration for the 'example' command
example:
patterns: # Define the patterns to use
- TARGET
exec: pmd
tool: cpd
language: cpp
minimum-tokens: 100
files: src/{TARGET}.cpp
command-line: # Set additional arguments
- --non-recursive
Additional files¶
In order for the above example to work, the following file hierarchy needs to be created in the directory:
Makefile:
CXX=g++
CXXFLAGS+=-O0 -g --coverage
LDFLAGS+=
SRC_DIR=src
BUILD_DIR=build
hello:
mkdir -p $(BUILD_DIR)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/hello $(SRC_DIR)/hello.cpp
world:
mkdir -p $(BUILD_DIR)
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $(BUILD_DIR)/world $(SRC_DIR)/world.cpp
clean:
rm -rf $(BUILD_DIR)
.PHONY: clean
hello.cpp:
#include <cstdlib>
#include <iostream>
auto main() -> int {
std::cout << "Hello" << std::endl;
return EXIT_SUCCESS;
}
world.cpp:
#include <cstdlib>
#include <iostream>
auto main() -> int {
std::cout << "World!" << std::endl;
return EXIT_SUCCESS;
}
Usage¶
Save the example to an exec-helper configuration file and execute in the same directory:
eh example
See also¶
See exec-helper (1) for information about the usage of exec-helper.
See Custom plugins (5) for the available plugins and their configuration options.
See Configuration (5) for information about the configuration file format.