Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
PDT Analysis
J2SE Best Practices for PDT
Static analysis
- Static code analysis is the analysis of computer software that is performed without actually executing programs built from that software. Objective: find properties on a given program.
- Step after semantic analysis
- Usages: compiler optimization like constant propagation, reachability. More: detecting logical errors
- The idea: build CFG [1] then run in “abstract mode” and do conservative operations to a least fixed point.
- Another tool is to check for best practices on the users code
Methods of usage
- Evaluating a 3rd party code
- Code Review
- Bug fixes
- Development
Using TPTP analysis tool
- Launch
- Launch Configuration
- Results
- Auto- fix (Ctrl + 1)
- Nightly reports - http://download.eclipse.org/tools/pdt/downloads/reports/ANALYSIS-php.html
Rules for example
- Severe: Override both hashCode() and equals()
- Warning: Always use break; in a case branch of a switch statement
- Recommendation: Using an if/else statement instead of a ternary operator makes code longer than necessary
Write your own rule
- Preferences-> Analysis ->Add Custom Rule
- Implement the Rule class
/** * Run the analysis portion * @param history A reference to the history record */ public void analyze( AnalysisHistory history);