Processing overview of the different steps taken by PMD.
Table of Contents
The processing starts with the main class
- Parse command line parameters (see net.sourceforge.pmd.cli.PMDParameters) Also load the incremental analysis cache file
- Load rulesets/rules
- Determine languages (rules of different languages might be mixed in rulesets)
- Determine files (uses the given source directory, filter by the language’s file extensions)
- Prepare the renderer
- Sort the files by name
- Check whether we can use the incremental analysis cache (if the rulesets changed, it will be invalid)
- Prepare the SourceCodeProcessor based on the configuration
- Analyze the files. Either single threaded or multi-threaded parallel. This task is encapsulated
- Create input stream
- Call source code processor (
- Determine the language
- Check whether the file is already analyzed and a result is available from the analysis cache
- Parse the source code. Result is the root AST node.
- Always run the SymbolFacade visitor. It builds scopes, finds declarations and usages.
- Run DFA (data flow analysis) visitor (if at least one rule requires it) for building control flow graphs and data flow nodes.
- Run TypeResolution visitor (if at least one rule requires it)
- FUTURE: Run multifile analysis (if at least one rule requires it)
- Execute the rules:
- First run the rules that opted in for the rule chain mechanism
- Run all the other rules and let them traverse the AST. The rules can use the symbol table, type resolution information and DFA nodes.
- The rules will report found problems as RuleViolations.
- Render the found violations into the wanted format (XML, text, HTML, …)
- Store the incremental analysis cache
- Depending on the number of violations found, exit with code 0 or 4.