ActiveRule activeRule = profile.getActiveRule(violation.getRule());
if (activeRule == null) {
if (currentProject.getReuseExistingRulesConfig()) {
- violation.setPriority(violation.getRule().getPriority());
+ violation.setSeverity(violation.getRule().getSeverity());
doAddViolation(violation, bucket);
} else {
String key() default "";
/**
- * The path to resource bundles (optional). If not set, then it equals the class name.
+ * The path to resource bundles (optional). If not set, then it equals the class name.
*/
String bundle() default "";
*/
Priority priority() default Priority.MAJOR;
-
/**
- * Will probably be deprecated and replaced by tags in version 2.2
+ * Will probably be deprecated and replaced by tags
+ *
+ * @deprecated since 2.5. See http://jira.codehaus.org/browse/SONAR-2007
*/
+ @Deprecated
IsoCategory isoCategory();
}
*
* @deprecated since 2.5. See http://jira.codehaus.org/browse/SONAR-2007
*/
+ @Deprecated
IsoCategory isoCategory() default IsoCategory.NONE;
Cardinality cardinality() default Cardinality.SINGLE;
-}
\ No newline at end of file
+}
import org.sonar.api.rules.RulePriority;
import javax.persistence.*;
+
import java.util.ArrayList;
import java.util.List;
@Column(name = "language", updatable = true, nullable = false)
private String language;
- @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE})
+ @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE })
private List<ActiveRule> activeRules = new ArrayList<ActiveRule>();
- @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE})
+ @OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE })
private List<Alert> alerts = new ArrayList<Alert>();
@OneToMany(mappedBy = "rulesProfile", fetch = FetchType.LAZY)
/**
* @return whether the profile is defined in a plugin. Provided profiles are automatically restored during
- * server startup and can not be updated by end users.
+ * server startup and can not be updated by end users.
*/
public Boolean getProvided() {
return provided;
}
/**
- *
+ *
* @param rule
* @param optionalPriority if null, then the default rule priority is used
* @return
ActiveRule activeRule = new ActiveRule();
activeRule.setRule(rule);
activeRule.setRulesProfile(this);
- activeRule.setPriority(optionalPriority==null ? rule.getPriority() : optionalPriority);
+ activeRule.setSeverity(optionalPriority == null ? rule.getSeverity() : optionalPriority);
activeRules.add(activeRule);
return activeRule;
}
import org.apache.commons.lang.builder.ToStringBuilder;
import org.sonar.api.profiles.RulesProfile;
+import javax.persistence.*;
+
import java.util.ArrayList;
import java.util.List;
-import javax.persistence.*;
/**
* A class to map an ActiveRule to the hibernate model
@Column(name = "failure_level", updatable = true, nullable = false)
@Enumerated(EnumType.ORDINAL)
- private RulePriority priority;
+ private RulePriority severity;
@ManyToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "profile_id", updatable = true, nullable = false)
private RulesProfile rulesProfile;
- @OneToMany(mappedBy = "activeRule", fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE})
+ @OneToMany(mappedBy = "activeRule", fetch = FetchType.LAZY, cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE })
private List<ActiveRuleParam> activeRuleParams = new ArrayList<ActiveRuleParam>();
/**
* @deprecated visibility should be reduced to protected or package
*/
@Deprecated
- public ActiveRule(RulesProfile profile, Rule rule, RulePriority priority) {
+ public ActiveRule(RulesProfile profile, Rule rule, RulePriority severity) {
this.rule = rule;
- if (priority == null && rule != null) {
- this.priority = rule.getPriority();
+ if (severity == null && rule != null) {
+ this.severity = rule.getSeverity();
} else {
- this.priority = priority;
+ this.severity = severity;
}
this.rulesProfile = profile;
}
/**
- * @deprecated visibility should be reduced to protected or package
+ * @deprecated visibility should be reduced to protected or package
*/
@Deprecated
public void setRule(Rule rule) {
this.rule = rule;
}
+ /**
+ * @since 2.5
+ */
+ public RulePriority getSeverity() {
+ return severity;
+ }
+
+ /**
+ * @since 2.5
+ */
+ public void setSeverity(RulePriority severity) {
+ this.severity = severity;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
public RulePriority getPriority() {
- return priority;
+ return severity;
}
+ /**
+ * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
public void setPriority(RulePriority priority) {
- this.priority = priority;
+ this.severity = priority;
}
public RulesProfile getRulesProfile() {
}
/**
- * @deprecated visibility should be reduced to protected or package
+ * @deprecated visibility should be reduced to protected or package
*/
@Deprecated
public void setRulesProfile(RulesProfile rulesProfile) {
@Override
public String toString() {
- return new ToStringBuilder(this).append("id", getId()).append("rule", rule).append("priority", priority).append("params", activeRuleParams).toString();
+ return new ToStringBuilder(this).append("id", getId()).append("rule", rule).append("priority", severity).append("params", activeRuleParams).toString();
}
@Override
public Object clone() {
- ActiveRule clone = new ActiveRule(getRulesProfile(), getRule(), getPriority());
+ ActiveRule clone = new ActiveRule(getRulesProfile(), getRule(), getSeverity());
if (CollectionUtils.isNotEmpty(getActiveRuleParams())) {
clone.setActiveRuleParams(new ArrayList<ActiveRuleParam>(CollectionUtils.collect(getActiveRuleParams(), new Transformer() {
public Object transform(Object input) {
import org.sonar.check.Cardinality;\r
\r
import javax.persistence.*;\r
+\r
import java.util.ArrayList;\r
import java.util.List;\r
\r
private Integer id;\r
\r
/**\r
- * The default priority given to a rule if not explicitely set\r
+ * The default priority given to a rule if not explicitly set\r
*/\r
public static final RulePriority DEFAULT_PRIORITY = RulePriority.MAJOR;\r
\r
\r
@Column(name = "priority", updatable = true, nullable = true)\r
@Enumerated(EnumType.ORDINAL)\r
- private RulePriority priority = DEFAULT_PRIORITY;\r
+ private RulePriority severity = DEFAULT_PRIORITY;\r
\r
@Column(name = "description", updatable = true, nullable = true, length = DatabaseProperties.MAX_TEXT_SIZE)\r
private String description;\r
@JoinColumn(name = "parent_id", updatable = true, nullable = true)\r
private Rule parent = null;\r
\r
- @org.hibernate.annotations.Cascade(\r
- {org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN}\r
-)\r
+ @org.hibernate.annotations.Cascade({ org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })\r
@OneToMany(mappedBy = "rule")\r
private List<RuleParam> params = new ArrayList<RuleParam>();\r
\r
/**\r
- * @deprecated since 2.3. Use the factory method create()\r
+ * @deprecated since 2.3. Use the factory method {@link #create()}\r
*/\r
@Deprecated\r
public Rule() {\r
\r
/**\r
* Creates rule with minimum set of info\r
- *\r
+ * \r
* @param pluginName the plugin name indicates which plugin the rule belongs to\r
- * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique\r
- * across the application\r
- * @deprecated since 2.3. Use the factory method create()\r
+ * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique\r
+ * across the application\r
+ * @deprecated since 2.3. Use the factory method {@link #create()}\r
*/\r
@Deprecated\r
public Rule(String pluginName, String key) {\r
\r
/**\r
* Creates a fully qualified rule\r
- *\r
- * @param pluginKey the plugin the rule belongs to\r
- * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique\r
- * across the application\r
- * @param name the name displayed in the UI\r
+ * \r
+ * @param pluginKey the plugin the rule belongs to\r
+ * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique\r
+ * across the application\r
+ * @param name the name displayed in the UI\r
* @param rulesCategory the ISO category the rule belongs to\r
- * @param priority this is the priority associated to the rule\r
- * @deprecated since 2.3. Use the factory method create()\r
+ * @param severity this is the severity associated to the rule\r
+ * @deprecated since 2.3. Use the factory method {@link #create()}\r
*/\r
@Deprecated\r
- public Rule(String pluginKey, String key, String name, RulesCategory rulesCategory, RulePriority priority) {\r
+ public Rule(String pluginKey, String key, String name, RulesCategory rulesCategory, RulePriority severity) {\r
setName(name);\r
this.key = key;\r
this.configKey = key;\r
- this.priority = priority;\r
+ this.severity = severity;\r
this.pluginName = pluginKey;\r
}\r
\r
/**\r
- * @deprecated Use the factory method create()\r
+ * @deprecated Use the factory method {@link #create()}\r
*/\r
@Deprecated\r
public Rule(String name, String key, RulesCategory rulesCategory, String pluginName, String description) {\r
}\r
\r
/**\r
- * @deprecated since 2.3. Use the factory method create()\r
+ * @deprecated since 2.3. Use the factory method {@link #create()}\r
*/\r
@Deprecated\r
public Rule(String name, String key, String configKey, RulesCategory rulesCategory, String pluginName, String description) {\r
}\r
\r
public RuleParam createParameter() {\r
- RuleParam parameter = new RuleParam();\r
- parameter.setRule(this);\r
+ RuleParam parameter = new RuleParam()\r
+ .setRule(this);\r
params.add(parameter);\r
return parameter;\r
}\r
\r
public RuleParam createParameter(String key) {\r
RuleParam parameter = new RuleParam()\r
- .setKey(key)\r
- .setRule(this);\r
+ .setKey(key)\r
+ .setRule(this);\r
params.add(parameter);\r
return parameter;\r
}\r
return null;\r
}\r
\r
- public RulePriority getPriority() {\r
- return priority;\r
+ /**\r
+ * @since 2.5\r
+ */\r
+ public RulePriority getSeverity() {\r
+ return severity;\r
}\r
\r
/**\r
- * Sets the rule priority. If null, uses the default priority\r
+ * @param severity severity to set, if null, uses the default priority.\r
+ * @since 2.5\r
*/\r
- public Rule setPriority(RulePriority priority) {\r
- if (priority == null) {\r
- this.priority = DEFAULT_PRIORITY;\r
+ public Rule setSeverity(RulePriority severity) {\r
+ if (severity == null) {\r
+ this.severity = DEFAULT_PRIORITY;\r
} else {\r
- this.priority = priority;\r
+ this.severity = severity;\r
}\r
-\r
return this;\r
}\r
\r
+ /**\r
+ * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829\r
+ */\r
+ @Deprecated\r
+ public RulePriority getPriority() {\r
+ return severity;\r
+ }\r
+\r
+ /**\r
+ * Sets the rule priority. If null, uses the default priority\r
+ * \r
+ * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829\r
+ */\r
+ @Deprecated\r
+ public Rule setPriority(RulePriority priority) {\r
+ return setSeverity(priority);\r
+ }\r
+\r
public String getRepositoryKey() {\r
return pluginName;\r
}\r
private Resource resource;
private Rule rule;
private String message;
- private RulePriority priority;
+ private RulePriority severity;
private Integer lineId;
private Double cost;
private Date createdAt;
return this;
}
+ /**
+ * @since 2.5
+ */
+ public RulePriority getSeverity() {
+ return severity;
+ }
+
+ /**
+ * For internal use only.
+ *
+ * @since 2.5
+ */
+ public Violation setSeverity(RulePriority severity) {
+ this.severity = severity;
+ return this;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public RulePriority getPriority() {
- return priority;
+ return severity;
}
/**
* For internal use only
+ *
+ * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829
*/
+ @Deprecated
public Violation setPriority(RulePriority priority) {
- this.priority = priority;
+ this.severity = priority;
return this;
}