diff options
7 files changed, 128 insertions, 59 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java index cf166a09eb6..ce98655f023 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java @@ -396,7 +396,7 @@ public final class DefaultIndex extends SonarIndex { 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 { diff --git a/sonar-check-api/src/main/java/org/sonar/check/Check.java b/sonar-check-api/src/main/java/org/sonar/check/Check.java index 6731d041560..274192d5dcc 100644 --- a/sonar-check-api/src/main/java/org/sonar/check/Check.java +++ b/sonar-check-api/src/main/java/org/sonar/check/Check.java @@ -39,7 +39,7 @@ public @interface Check { 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 ""; @@ -58,9 +58,11 @@ public @interface Check { */ 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(); } diff --git a/sonar-check-api/src/main/java/org/sonar/check/Rule.java b/sonar-check-api/src/main/java/org/sonar/check/Rule.java index fe99c2e1c22..905c59b4099 100644 --- a/sonar-check-api/src/main/java/org/sonar/check/Rule.java +++ b/sonar-check-api/src/main/java/org/sonar/check/Rule.java @@ -56,7 +56,8 @@ public @interface Rule { * * @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 +} diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java index 43773eed22a..3ed3125a2c1 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/RulesProfile.java @@ -30,6 +30,7 @@ import org.sonar.api.rules.Rule; import org.sonar.api.rules.RulePriority; import javax.persistence.*; + import java.util.ArrayList; import java.util.List; @@ -73,10 +74,10 @@ public class RulesProfile implements Cloneable { @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) @@ -161,7 +162,7 @@ public class RulesProfile implements Cloneable { /** * @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; @@ -274,7 +275,7 @@ public class RulesProfile implements Cloneable { } /** - * + * * @param rule * @param optionalPriority if null, then the default rule priority is used * @return @@ -283,7 +284,7 @@ public class RulesProfile implements Cloneable { 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; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java index 86cccee0860..a57bc3c21bb 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java @@ -25,9 +25,10 @@ import org.apache.commons.lang.StringUtils; 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 @@ -47,13 +48,13 @@ public class ActiveRule implements Cloneable { @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>(); /** @@ -67,12 +68,12 @@ public class ActiveRule implements Cloneable { * @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; @@ -95,19 +96,39 @@ public class ActiveRule implements Cloneable { } /** - * @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() { @@ -115,7 +136,7 @@ public class ActiveRule implements Cloneable { } /** - * @deprecated visibility should be reduced to protected or package + * @deprecated visibility should be reduced to protected or package */ @Deprecated public void setRulesProfile(RulesProfile rulesProfile) { @@ -209,12 +230,12 @@ public class ActiveRule implements Cloneable { @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) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java index dcba3549df4..9db472fedd1 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Rule.java @@ -27,6 +27,7 @@ import org.sonar.api.database.DatabaseProperties; import org.sonar.check.Cardinality;
import javax.persistence.*;
+
import java.util.ArrayList;
import java.util.List;
@@ -40,7 +41,7 @@ public final class Rule { private Integer id;
/**
- * The default priority given to a rule if not explicitely set
+ * The default priority given to a rule if not explicitly set
*/
public static final RulePriority DEFAULT_PRIORITY = RulePriority.MAJOR;
@@ -58,7 +59,7 @@ public final class Rule { @Column(name = "priority", updatable = true, nullable = true)
@Enumerated(EnumType.ORDINAL)
- private RulePriority priority = DEFAULT_PRIORITY;
+ private RulePriority severity = DEFAULT_PRIORITY;
@Column(name = "description", updatable = true, nullable = true, length = DatabaseProperties.MAX_TEXT_SIZE)
private String description;
@@ -74,14 +75,12 @@ public final class Rule { @JoinColumn(name = "parent_id", updatable = true, nullable = true)
private Rule parent = null;
- @org.hibernate.annotations.Cascade(
- {org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN}
-)
+ @org.hibernate.annotations.Cascade({ org.hibernate.annotations.CascadeType.ALL, org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
@OneToMany(mappedBy = "rule")
private List<RuleParam> params = new ArrayList<RuleParam>();
/**
- * @deprecated since 2.3. Use the factory method create()
+ * @deprecated since 2.3. Use the factory method {@link #create()}
*/
@Deprecated
public Rule() {
@@ -90,11 +89,11 @@ public final class Rule { /**
* Creates rule with minimum set of info
- *
+ *
* @param pluginName the plugin name indicates which plugin the rule belongs to
- * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique
- * across the application
- * @deprecated since 2.3. Use the factory method create()
+ * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique
+ * across the application
+ * @deprecated since 2.3. Use the factory method {@link #create()}
*/
@Deprecated
public Rule(String pluginName, String key) {
@@ -105,26 +104,26 @@ public final class Rule { /**
* Creates a fully qualified rule
- *
- * @param pluginKey the plugin the rule belongs to
- * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique
- * across the application
- * @param name the name displayed in the UI
+ *
+ * @param pluginKey the plugin the rule belongs to
+ * @param key the key should be unique within a plugin, but it is even more careful for the time being that it is unique
+ * across the application
+ * @param name the name displayed in the UI
* @param rulesCategory the ISO category the rule belongs to
- * @param priority this is the priority associated to the rule
- * @deprecated since 2.3. Use the factory method create()
+ * @param severity this is the severity associated to the rule
+ * @deprecated since 2.3. Use the factory method {@link #create()}
*/
@Deprecated
- public Rule(String pluginKey, String key, String name, RulesCategory rulesCategory, RulePriority priority) {
+ public Rule(String pluginKey, String key, String name, RulesCategory rulesCategory, RulePriority severity) {
setName(name);
this.key = key;
this.configKey = key;
- this.priority = priority;
+ this.severity = severity;
this.pluginName = pluginKey;
}
/**
- * @deprecated Use the factory method create()
+ * @deprecated Use the factory method {@link #create()}
*/
@Deprecated
public Rule(String name, String key, RulesCategory rulesCategory, String pluginName, String description) {
@@ -137,7 +136,7 @@ public final class Rule { }
/**
- * @deprecated since 2.3. Use the factory method create()
+ * @deprecated since 2.3. Use the factory method {@link #create()}
*/
@Deprecated
public Rule(String name, String key, String configKey, RulesCategory rulesCategory, String pluginName, String description) {
@@ -275,16 +274,16 @@ public final class Rule { }
public RuleParam createParameter() {
- RuleParam parameter = new RuleParam();
- parameter.setRule(this);
+ RuleParam parameter = new RuleParam()
+ .setRule(this);
params.add(parameter);
return parameter;
}
public RuleParam createParameter(String key) {
RuleParam parameter = new RuleParam()
- .setKey(key)
- .setRule(this);
+ .setKey(key)
+ .setRule(this);
params.add(parameter);
return parameter;
}
@@ -297,23 +296,44 @@ public final class Rule { return null;
}
- public RulePriority getPriority() {
- return priority;
+ /**
+ * @since 2.5
+ */
+ public RulePriority getSeverity() {
+ return severity;
}
/**
- * Sets the rule priority. If null, uses the default priority
+ * @param severity severity to set, if null, uses the default priority.
+ * @since 2.5
*/
- public Rule setPriority(RulePriority priority) {
- if (priority == null) {
- this.priority = DEFAULT_PRIORITY;
+ public Rule setSeverity(RulePriority severity) {
+ if (severity == null) {
+ this.severity = DEFAULT_PRIORITY;
} else {
- this.priority = priority;
+ 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 severity;
+ }
+
+ /**
+ * Sets the rule priority. If null, uses the default priority
+ *
+ * @deprecated since 2.5 use {@link #setSeverity(RulePriority)} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
+ public Rule setPriority(RulePriority priority) {
+ return setSeverity(priority);
+ }
+
public String getRepositoryKey() {
return pluginName;
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java index 391170ce76a..ceab5652c7e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/Violation.java @@ -34,7 +34,7 @@ public class Violation { private Resource resource; private Rule rule; private String message; - private RulePriority priority; + private RulePriority severity; private Integer lineId; private Double cost; private Date createdAt; @@ -121,15 +121,39 @@ public class Violation { 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; } |