Skip to main content

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.

Jump to: navigation, search

Difference between revisions of "PDT Analysis"

(J2SE Best Practices for PDT)
(J2SE Best Practices for PDT)
 
Line 37: Line 37:
 
public void analyze( AnalysisHistory history);
 
public void analyze( AnalysisHistory history);
 
</pre>
 
</pre>
 +
 +
== FindBugs™ for PDT ==
 +
FindBugs looks for bugs in Java programs.  It is based on the concept of bug patterns.  A bug pattern is a code idiom that is often an error.  Bug patterns arise for a variety of reasons:
 +
* Difficult language features
 +
* Misunderstood API methods
 +
* Misunderstood invariants when code is modified during maintenance
 +
* Garden variety mistakes: typos, use of the wrong boolean operator
 +
<br>
 +
FindBugs uses static analysis to inspect Java bytecode for occurrences of bug patterns.  Static analysis means that FindBugs can find bugs by simply inspecting a program's code: executing the program is not necessary.  This makes FindBugs very easy to use: in general, you should be able to use it to look for bugs in your code within a few minutes of downloading it.  FindBugs works by analyzing Java bytecode (compiled class files), so you don't even need the program's source code to use it.  Because its analysis is sometimes imprecise, FindBugs can report false warnings, which are warnings that do not indicate real errors.  In practice, the rate of false warnings reported by FindBugs is less than 50%.
 +
<br>
 +
PDT report is produced during the nightly build and available [http://download.eclipse.org/tools/pdt/downloads/drops/results/FINDBUGS-php.html here]
 +
 +
more information on FindBugs™ : http://findbugs.sourceforge.net/

Latest revision as of 03:53, 13 August 2007

J2SE Best Practices for PDT

Static analysis

  1. 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.
  2. Step after semantic analysis
  3. Usages: compiler optimization like constant propagation, reachability. More: detecting logical errors
  4. The idea: build CFG [1] then run in “abstract mode” and do conservative operations to a least fixed point.
  5. Another tool is to check for best practices on the users code

Methods of usage

  1. Evaluating a 3rd party code
  2. Code Review
  3. Bug fixes
  4. Development

Using TPTP analysis tool

  1. DL - http://www.eclipse.org/tptp/home/downloads/?ver=4.4.0
  2. Launch
  3. Launch Configuration
  4. Results
  5. Auto- fix (Ctrl + 1)
  6. Nightly reports - http://download.eclipse.org/tools/pdt/downloads/reports/ANALYSIS-php.html

Rules for example

  1. Severe: Override both hashCode() and equals()
  2. Warning: Always use break; in a case branch of a switch statement
  3. Recommendation: Using an if/else statement instead of a ternary operator makes code longer than necessary

Write your own rule

  1. Preferences-> Analysis ->Add Custom Rule
  2. Implement the Rule class
	/**
	 * Run the analysis portion 
	 * @param history	A reference to the history record 
	 */
	public void analyze( AnalysisHistory history);

FindBugs™ for PDT

FindBugs looks for bugs in Java programs. It is based on the concept of bug patterns. A bug pattern is a code idiom that is often an error. Bug patterns arise for a variety of reasons:

  • Difficult language features
  • Misunderstood API methods
  • Misunderstood invariants when code is modified during maintenance
  • Garden variety mistakes: typos, use of the wrong boolean operator


FindBugs uses static analysis to inspect Java bytecode for occurrences of bug patterns. Static analysis means that FindBugs can find bugs by simply inspecting a program's code: executing the program is not necessary. This makes FindBugs very easy to use: in general, you should be able to use it to look for bugs in your code within a few minutes of downloading it. FindBugs works by analyzing Java bytecode (compiled class files), so you don't even need the program's source code to use it. Because its analysis is sometimes imprecise, FindBugs can report false warnings, which are warnings that do not indicate real errors. In practice, the rate of false warnings reported by FindBugs is less than 50%.
PDT report is produced during the nightly build and available here

more information on FindBugs™ : http://findbugs.sourceforge.net/

Back to the top