org.sonar.api.rules
Class Violation

java.lang.Object
  extended by org.sonar.api.rules.Violation

Deprecated. in 3.6. Replaced by Issue.

@Deprecated
public class Violation
extends Object

A class that represents a violation. A violation happens when a resource does not respect a defined rule.


Constructor Summary
Violation(Rule rule)
          Deprecated. since 2.3. Use the factory method create()
Violation(Rule rule, Resource resource)
          Deprecated. since 2.3. Use the factory method create()
 
Method Summary
static Violation create(ActiveRule activeRule, Resource resource)
          Deprecated.  
static Violation create(Rule rule, Resource resource)
          Deprecated.  
 String getChecksum()
          Deprecated. Checksum is available in decorators executed after the barrier DecoratorBarriers.END_OF_VIOLATION_TRACKING
 Double getCost()
          Deprecated.  
 Date getCreatedAt()
          Deprecated.  
 Integer getLineId()
          Deprecated.  
 String getMessage()
          Deprecated.  
 Integer getPermanentId()
          Deprecated. For internal use only.
 Integer getPersonId()
          Deprecated.  
 RulePriority getPriority()
          Deprecated. since 2.5 use getSeverity() instead. See http://jira.codehaus.org/browse/SONAR-1829
 Resource getResource()
          Deprecated.  
 Rule getRule()
          Deprecated.  
 RulePriority getSeverity()
          Deprecated.  
 boolean hasLineId()
          Deprecated.  
 boolean isManual()
          Deprecated.  
 boolean isNew()
          Deprecated. A violation is considered as "new" if it has been created after the reference analysis (the "previous" analysis).
 boolean isSwitchedOff()
          Deprecated. Tells whether this violation is ON or OFF.
 Violation setChecksum(String s)
          Deprecated. For internal use only.
 Violation setCost(Double d)
          Deprecated. The cost to fix a violation can't be precisely computed without this information.
 Violation setCreatedAt(Date createdAt)
          Deprecated. For internal use only
 Violation setLineId(Integer lineId)
          Deprecated. Sets the violation line.
 Violation setManual(boolean b)
          Deprecated. For internal use only.
 Violation setMessage(String message)
          Deprecated. Sets the violation message
 Violation setNew(boolean b)
          Deprecated. For internal use only.
 Violation setPermanentId(Integer i)
          Deprecated. For internal use only.
 Violation setPersonId(Integer i)
          Deprecated. For internal use only.
 Violation setPriority(RulePriority priority)
          Deprecated. since 2.5 use setSeverity(RulePriority) instead. See http://jira.codehaus.org/browse/SONAR-1829
 Violation setResource(Resource resource)
          Deprecated. Sets the resource the violation applies to
 Violation setRule(Rule rule)
          Deprecated. Sets the rule violated
 Violation setSeverity(RulePriority severity)
          Deprecated. For internal use only.
 Violation setSwitchedOff(boolean b)
          Deprecated. Switches off the current violation.
 String toString()
          Deprecated.  
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Violation

@Deprecated
public Violation(Rule rule)
Deprecated. since 2.3. Use the factory method create()

Creates of a violation from a rule. Will need to define the resource later on


Violation

@Deprecated
public Violation(Rule rule,
                            Resource resource)
Deprecated. since 2.3. Use the factory method create()

Creates a fully qualified violation

Parameters:
rule - the rule that has been violated
resource - the resource the violation should be attached to
Method Detail

getResource

public Resource getResource()
Deprecated. 

setResource

public Violation setResource(Resource resource)
Deprecated. 
Sets the resource the violation applies to

Returns:
the current object

getRule

public Rule getRule()
Deprecated. 

setRule

public Violation setRule(Rule rule)
Deprecated. 
Sets the rule violated

Returns:
the current object

getMessage

public String getMessage()
Deprecated. 

setMessage

public Violation setMessage(String message)
Deprecated. 
Sets the violation message

Returns:
the current object

getLineId

public Integer getLineId()
Deprecated. 
Returns:
line number (numeration starts from 1), or null if violation doesn't belong to concrete line
See Also:
hasLineId()

setLineId

public Violation setLineId(Integer lineId)
Deprecated. 
Sets the violation line.

Parameters:
lineId - line number (numeration starts from 1), or null if violation doesn't belong to concrete line
Returns:
the current object

hasLineId

public boolean hasLineId()
Deprecated. 
Returns:
true if violation belongs to concrete line
Since:
2.8

getSeverity

public RulePriority getSeverity()
Deprecated. 
Since:
2.5

setSeverity

public Violation setSeverity(RulePriority severity)
Deprecated. 
For internal use only.

Since:
2.5

getPriority

@Deprecated
public RulePriority getPriority()
Deprecated. since 2.5 use getSeverity() instead. See http://jira.codehaus.org/browse/SONAR-1829


setPriority

@Deprecated
public Violation setPriority(RulePriority priority)
Deprecated. since 2.5 use setSeverity(RulePriority) instead. See http://jira.codehaus.org/browse/SONAR-1829

For internal use only


getCost

public Double getCost()
Deprecated. 
Since:
2.4
See Also:
setCost(Double)

setCost

public Violation setCost(Double d)
Deprecated. 
The cost to fix a violation can't be precisely computed without this information. Let's take the following example : a rule forbids to have methods whose complexity is greater than 10. Without this field "cost", the same violation is created with a method whose complexity is 15 and a method whose complexity is 100. If the cost to fix one point of complexity is 0.05h, then 15mn is necessary to fix the method whose complexity is 15, and 3h5mn is required to fix the method whose complexity is 100.

Since:
2.4

getCreatedAt

public Date getCreatedAt()
Deprecated. 
Since:
2.5

setCreatedAt

public Violation setCreatedAt(Date createdAt)
Deprecated. 
For internal use only

Since:
2.5

setSwitchedOff

public Violation setSwitchedOff(boolean b)
Deprecated. 
Switches off the current violation. This is a kind of "mute", which means the violation exists but won't be counted as an active violation (and thus, won't be counted in the total number of violations). It's usually used for false-positives.

The extensions which call this method must be executed

Parameters:
b - if true, the violation is considered OFF
Since:
2.8

isSwitchedOff

public boolean isSwitchedOff()
Deprecated. 
Tells whether this violation is ON or OFF.

Since:
2.8

getChecksum

public String getChecksum()
Deprecated. 
Checksum is available in decorators executed after the barrier DecoratorBarriers.END_OF_VIOLATION_TRACKING


setChecksum

public Violation setChecksum(String s)
Deprecated. 
For internal use only. Checksum is automatically set by Sonar. Plugins must not call this method.


isNew

public boolean isNew()
Deprecated. 
A violation is considered as "new" if it has been created after the reference analysis (the "previous" analysis). This method must be used only by post-jobs and decorators depending on the barrier DecoratorBarriers.END_OF_VIOLATION_TRACKING

Since:
2.9

setNew

public Violation setNew(boolean b)
Deprecated. 
For internal use only. MUST NOT BE SET FROM PLUGINS.

Since:
2.9

isManual

public boolean isManual()
Deprecated. 
Since:
2.13

setManual

public Violation setManual(boolean b)
Deprecated. 
For internal use only. MUST NOT BE SET FROM PLUGINS.

Since:
2.13

getPermanentId

public Integer getPermanentId()
Deprecated. 
For internal use only. MUST NOT BE SET FROM PLUGINS.

Since:
2.13

setPermanentId

public Violation setPermanentId(Integer i)
Deprecated. 
For internal use only. MUST NOT BE SET FROM PLUGINS.

Since:
2.13

getPersonId

public Integer getPersonId()
Deprecated. 
Since:
2.13

setPersonId

public Violation setPersonId(Integer i)
Deprecated. 
For internal use only.

Since:
2.13

toString

public String toString()
Deprecated. 
Overrides:
toString in class Object

create

public static Violation create(ActiveRule activeRule,
                               Resource resource)
Deprecated. 

create

public static Violation create(Rule rule,
                               Resource resource)
Deprecated. 


Copyright © 2009-2013 SonarSource. All Rights Reserved.