public class PMD extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
PMD.ProgressMonitor
A callback that would be implemented by IDEs keeping track of PMD's
progress as it evaluates a set of files.
|
Modifier and Type | Field and Description |
---|---|
protected PMDConfiguration |
configuration
Contains the configuration with which this PMD instance has been created.
|
static String |
EOL
The line delimiter used by PMD in outputs.
|
static String |
SUPPRESS_MARKER
The default suppress marker string.
|
static String |
VERSION
Constant that contains always the current version of PMD.
|
Constructor and Description |
---|
PMD()
Create a PMD instance using a default Configuration.
|
PMD(PMDConfiguration configuration)
Create a PMD instance using the specified Configuration.
|
Modifier and Type | Method and Description |
---|---|
static int |
doPMD(PMDConfiguration configuration)
This method is the main entry point for command line usage.
|
static List<DataSource> |
getApplicableFiles(PMDConfiguration configuration,
Set<Language> languages)
Determines all the files, that should be analyzed by PMD.
|
PMDConfiguration |
getConfiguration()
Get the runtime configuration.
|
SourceCodeProcessor |
getSourceCodeProcessor()
Gets the source code processor.
|
static List<DataSource> |
getURIDataSources(String uriString)
Parses the given string as a database uri and returns a list of datasources.
|
static void |
main(String[] args)
Entry to invoke PMD as command line tool
|
static RuleContext |
newRuleContext(String sourceCodeFilename,
File sourceCodeFile)
Creates a new rule context, initialized with a new, empty report.
|
static Parser |
parserFor(LanguageVersion languageVersion,
PMDConfiguration configuration)
Helper method to get a configured parser for the requested language.
|
static void |
processFiles(PMDConfiguration configuration,
RuleSetFactory ruleSetFactory,
Collection<File> files,
RuleContext ctx,
PMD.ProgressMonitor monitor)
An entry point that would typically be used by IDEs intent on providing
ongoing feedback and the ability to terminate it at will.
|
static void |
processFiles(PMDConfiguration configuration,
RuleSetFactory ruleSetFactory,
List<DataSource> files,
RuleContext ctx,
List<Renderer> renderers)
Run PMD on a list of files using multiple threads - if more than one is
available
|
static int |
run(String[] args)
Parses the command line arguments and executes PMD.
|
static Report |
setupReport(RuleSets rs,
RuleContext ctx,
String fileName)
Create a report, filter out any defective rules, and keep a record of
them.
|
public static final String EOL
public static final String SUPPRESS_MARKER
protected final PMDConfiguration configuration
public static final String VERSION
public PMD()
public PMD(PMDConfiguration configuration)
configuration
- The runtime Configuration of PMD to use.public static List<DataSource> getURIDataSources(String uriString) throws PMDException
uriString
- the URI to parsePMDException
- if the URI couldn't be parsedDBURI
public static Parser parserFor(LanguageVersion languageVersion, PMDConfiguration configuration)
PMDConfiguration
.languageVersion
- the requested languageconfiguration
- the given configurationpublic static Report setupReport(RuleSets rs, RuleContext ctx, String fileName)
rs
- the rulesctx
- the rule contextfileName
- the filename of the source file, which should appear in the reportpublic PMDConfiguration getConfiguration()
PMDConfiguration
public SourceCodeProcessor getSourceCodeProcessor()
public static int doPMD(PMDConfiguration configuration)
configuration
- the configure to usepublic static RuleContext newRuleContext(String sourceCodeFilename, File sourceCodeFile)
sourceCodeFilename
- the source code filenamesourceCodeFile
- the source code filepublic static void processFiles(PMDConfiguration configuration, RuleSetFactory ruleSetFactory, Collection<File> files, RuleContext ctx, PMD.ProgressMonitor monitor)
configuration
- the PMD configuration to useruleSetFactory
- ruleset factoryfiles
- the files to analyzectx
- the rule context to use for the executionmonitor
- PMD informs about the progress through this progress monitor. It provides also
the ability to terminate/cancel the execution.public static void processFiles(PMDConfiguration configuration, RuleSetFactory ruleSetFactory, List<DataSource> files, RuleContext ctx, List<Renderer> renderers)
configuration
- ConfigurationruleSetFactory
- RuleSetFactoryfiles
- Listctx
- RuleContextrenderers
- Listpublic static List<DataSource> getApplicableFiles(PMDConfiguration configuration, Set<Language> languages)
configuration
- contains either the file path or the DB URI, from where to load the fileslanguages
- used to filter by file extensionpublic static void main(String[] args)
args
- command line argumentspublic static int run(String[] args)
args
- command line arguments0
means successful execution, 1
means error,
4
means there have been violations found.Copyright © 2002-2015 InfoEther. All Rights Reserved.