org.jcoderz.phoenix.report
Class Severity

java.lang.Object
  extended by org.jcoderz.phoenix.report.Severity
All Implemented Interfaces:
Serializable, Comparable

public final class Severity
extends Object
implements Serializable, Comparable

Enumerated type of a severity.

The severity of a finding shall reflect the urgency of a fix needed. Higher severity levels require more urgent actions where lower levels might denote findings that are for information only.

This class also defines the weight of a finding (getPenalty() and thus how much the quality is affected by the finding of this severity.

Instances of this class are immutable.

The following severities are defined:

  1. CPD
  2. WARNING
  3. DESIGN
  4. CODE_STYLE
  5. INFO
  6. COVERAGE
  7. FILTERED

Author:
Andreas Mandel
See Also:
Serialized Form

Field Summary
static Severity CODE_STYLE
          Severity for code-style type of findings.
static Severity COVERAGE
          Severity for code that is not covered by test cases.
static Severity CPD
          Detected copied & pasted code.
static Severity DESIGN
          This severity level is for design related findings.
static Severity ERROR
          Severe findings requiring immediate action.
static Severity FILTERED
          Severity for filtered findings.
static Severity INFO
          Severity for informational finders like to-do markers or code that uses outdated API which should be updated but has no side effect.
static Severity MAX_SEVERITY
          The maximum possible severity.
static int MAX_SEVERITY_INT
          The maximum possible severity as int.
static Severity OK
          Severity level used to denote no finding.
static int PENALTY_SCALE
          Scale of the penalty points.
static List VALUES
          Immutable list of the severities.
static Severity WARNING
          Warning level severities.
 
Method Summary
 int compareTo(Object o)
          
 boolean equals(Object o)
          
static Severity fromFindBugsPriority(String priority)
          Parses the findbugs severity representation.
static Severity fromInt(int i)
          Creates a Severity object from its int representation.
static Severity fromString(String str)
          Creates a Severity object from its String representation.
 int getPenalty()
          Returns the penalty assigned to findings of this severity.
 int hashCode()
          
 Severity max(Severity other)
          Returns the maximum severe code of this and the given severity.
 String toFindBugsPriority()
          Converts the jCoderZ priority in the FindBugs XML representation.
 int toInt()
          Returns the int representation of this severity.
 String toString()
          Returns the String representation of this severity.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

PENALTY_SCALE

public static final int PENALTY_SCALE
Scale of the penalty points. One penalty point marks 1 / PENALTY_SCALE lines as bad.

See Also:
Constant Field Values

FILTERED

public static final Severity FILTERED
Severity for filtered findings.

Findings that are not appropriate for whatever reason (ex. being a false positive) should get this level assigned by the filtering style sheet.

A finding of this severity marks no lines of code as bad.


OK

public static final Severity OK
Severity level used to denote no finding.


INFO

public static final Severity INFO
Severity for informational finders like to-do markers or code that uses outdated API which should be updated but has no side effect.

A finding of this severity marks no lines of code as bad.


CODE_STYLE

public static final Severity CODE_STYLE
Severity for code-style type of findings.

All finders that report indentation, position of braces or this kind of violation should use this level. There is no deeper differentiation for this type of findings.

A finding of this severity marks 0.5 lines of code as bad.


COVERAGE

public static final Severity COVERAGE
Severity for code that is not covered by test cases.

If code coverage is enabled each line with a coverage of 0 gets marked with this violation.

A finding of this severity marks 0.8 lines of code as bad.


DESIGN

public static final Severity DESIGN
This severity level is for design related findings.

Inheritance problems or broken implementation of standard methods should get this severity level, unless ERROR or WARNING fits better.

A finding of this severity marks three lines of code as bad.


WARNING

public static final Severity WARNING
Warning level severities.

A finding of this severity marks 5 lines of code as bad.


CPD

public static final Severity CPD
Detected copied & pasted code.

The copy and paste detector detected a number of similar lines at a different position. This should be refactored immediately.

A finding of this severity marks 10 lines of code as bad.


ERROR

public static final Severity ERROR
Severe findings requiring immediate action.

Findings of this severity are serious errors. Finders that detect style or design violations or finders that produce a certain number of false positives must not use this severity.

Findings of this severity should prevent a project from being released. A severity of this level marks 10 lines as bad.


MAX_SEVERITY

public static final Severity MAX_SEVERITY
The maximum possible severity. Is ERROR.


MAX_SEVERITY_INT

public static final int MAX_SEVERITY_INT
The maximum possible severity as int.


VALUES

public static final List VALUES
Immutable list of the severities.

Method Detail

fromInt

public static Severity fromInt(int i)
                        throws IllegalArgumentException
Creates a Severity object from its int representation.

Parameters:
i - the int representation of the severity to be returned.
Returns:
the Severity object represented by this int.
Throws:
IllegalArgumentException - If the assigned int value isn't listed in the internal severity table

fromString

public static Severity fromString(String str)
                           throws IllegalArgumentException
Creates a Severity object from its String representation.

Parameters:
str - the string representation of the severity to be returned.
Returns:
the Severity object represented by this string.
Throws:
IllegalArgumentException - If the given string value isn't listed in the internal severity table

toInt

public int toInt()
Returns the int representation of this severity.

Returns:
the int representation of this severity.

toString

public String toString()
Returns the String representation of this severity.

Overrides:
toString in class Object
Returns:
the String representation of this severity.

getPenalty

public int getPenalty()
Returns the penalty assigned to findings of this severity. The number is the ten times the number of lines a finding of this severity should mark as bad.

Returns:
the penalty assigned to this severity.

compareTo

public int compareTo(Object o)

Specified by:
compareTo in interface Comparable

equals

public boolean equals(Object o)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

fromFindBugsPriority

public static Severity fromFindBugsPriority(String priority)
Parses the findbugs severity representation.

Parameters:
priority - the string read from the xml
Returns:
the jCoderZ severity representation.

toFindBugsPriority

public String toFindBugsPriority()
Converts the jCoderZ priority in the FindBugs XML representation.

Returns:
the jCoderZ priority in FindBugs XML representation.

max

public Severity max(Severity other)
Returns the maximum severe code of this and the given severity.

Parameters:
other - the severity to compare with.
Returns:
the maximum severe code of this and the given severity.


Copyright 2007 The jCoderZ Project.