@Before
public void before() {
- ruleA1 = Rule.create().setPluginName("ruleA1").setKey("ruleA1").setName("nameA1");
- ruleA2 = Rule.create().setPluginName("ruleA2").setKey("ruleA2").setName("nameA2");
- ruleB1 = Rule.create().setPluginName("ruleB1").setKey("ruleB1").setName("nameB1");
+ ruleA1 = Rule.create().setRepositoryKey("ruleA1").setKey("ruleA1").setName("nameA1");
+ ruleA2 = Rule.create().setRepositoryKey("ruleA2").setKey("ruleA2").setName("nameA2");
+ ruleB1 = Rule.create().setRepositoryKey("ruleB1").setKey("ruleB1").setName("nameB1");
decorator = new ViolationsDecorator();
resource = mock(Resource.class);
decorator = new NewViolationsDecorator(timeMachineConfiguration);
- rule1 = Rule.create().setPluginName("rule1").setKey("rule1").setName("name1");
- rule2 = Rule.create().setPluginName("rule2").setKey("rule2").setName("name2");
- rule3 = Rule.create().setPluginName("rule3").setKey("rule3").setName("name3");
+ rule1 = Rule.create().setRepositoryKey("rule1").setKey("rule1").setName("name1");
+ rule2 = Rule.create().setRepositoryKey("rule2").setKey("rule2").setName("name2");
+ rule3 = Rule.create().setRepositoryKey("rule3").setKey("rule3").setName("name3");
}
@Test
return getSession().getResults(Rule.class, "enabled", true);\r
}\r
\r
- public List<Rule> getRulesByPlugin(String pluginKey) {\r
- return getSession().getResults(Rule.class, "pluginName", pluginKey, "enabled", true);\r
+ public List<Rule> getRulesByRepository(String repositoryKey) {\r
+ return getSession().getResults(Rule.class, "pluginName", repositoryKey, "enabled", true);\r
}\r
\r
+ /**\r
+ * @deprecated since 2.5 use {@link #getRulesByRepository(String)} instead.\r
+ */\r
+ @Deprecated\r
+ public List<Rule> getRulesByPlugin(String pluginKey) {\r
+ return getRulesByRepository(pluginKey);\r
+ }\r
\r
- public Rule getRuleByKey(String pluginKey, String ruleKey) {\r
- return getSession().getSingleResult(Rule.class, "key", ruleKey, "pluginName", pluginKey, "enabled", true);\r
+ public Rule getRuleByKey(String repositoryKey, String ruleKey) {\r
+ return getSession().getSingleResult(Rule.class, "key", ruleKey, "pluginName", repositoryKey, "enabled", true);\r
}\r
\r
public Long countRules(List<String> plugins) {\r
getSingleResult();\r
}\r
\r
-\r
public List<RuleParam> getRuleParams() {\r
return getSession().getResults(RuleParam.class);\r
}\r
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RulePriority;
-import javax.persistence.*;
-
import java.util.ArrayList;
import java.util.List;
+import javax.persistence.*;
+
/**
- * This class is badly named. It should be "QualityProfile". Indeed it does not relate only to rules but to metric
- * thresholds too.
+ * This class is badly named. It should be "QualityProfile". Indeed it does not relate only to rules but to metric thresholds too.
*/
@Entity
@Table(name = "rules_profiles")
}
/**
- * Set whether this is the default profile for the language. The default profile is used when none is explicitly
- * defined when auditing a project.
+ * Set whether this is the default profile for the language. The default profile is used when none is explicitly defined when auditing a
+ * project.
*/
public void setDefaultProfile(Boolean b) {
this.defaultProfile = b;
}
/**
- * @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.
+ * @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.
*/
public Boolean getProvided() {
return provided;
}
/**
- * @deprecated since 2.3. Use getActiveRulesByRepository().
+ * @deprecated since 2.3 use {@link #getActiveRulesByRepository()} instead.
*/
@Deprecated
public List<ActiveRule> getActiveRulesByPlugin(String repositoryKey) {
public List<ActiveRule> getActiveRulesByRepository(String repositoryKey) {
List<ActiveRule> result = new ArrayList<ActiveRule>();
for (ActiveRule activeRule : getActiveRules()) {
- if (repositoryKey.equals(activeRule.getPluginName())) {
+ if (repositoryKey.equals(activeRule.getRepositoryKey())) {
result.add(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
*/
}
/**
- * @deprecated use getRepositoryKey()
+ * @deprecated since 2.3 use {@link #getRepositoryKey()} instead
*/
@Deprecated
public String getPluginName() {
- return rule.getPluginName();
+ return rule.getRepositoryKey();
}
public String getRepositoryKey() {
@Override
public String toString() {
- return new ToStringBuilder(this).append("id", getId()).append("rule", rule).append("priority", severity).append("params", activeRuleParams).toString();
+ return new ToStringBuilder(this).append("id", getId()).append("rule", rule).append("priority", severity)
+ .append("params", activeRuleParams).toString();
}
@Override
import org.sonar.api.database.DatabaseProperties;\r
import org.sonar.check.Cardinality;\r
\r
-import javax.persistence.*;\r
-\r
import java.util.ArrayList;\r
import java.util.List;\r
\r
+import javax.persistence.*;\r
+\r
@Entity\r
@Table(name = "rules")\r
public final class Rule {\r
* Creates rule with minimum set of info\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
+ * @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\r
+ * application\r
* @deprecated since 2.3. Use the factory method {@link #create()}\r
*/\r
@Deprecated\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 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\r
+ * application\r
* @param name the name displayed in the UI\r
* @param rulesCategory the ISO category the rule belongs to\r
* @param severity this is the severity associated to the rule\r
return this;\r
}\r
\r
+ /**\r
+ * @deprecated since 2.5 use {@link #getRepositoryKey()} instead\r
+ */\r
+ @Deprecated\r
public String getPluginName() {\r
return pluginName;\r
}\r
\r
/**\r
- * Sets the plugin name the rule belongs to\r
+ * @deprecated since 2.5 use {@link #setRepositoryKey(String)} instead\r
*/\r
+ @Deprecated\r
public Rule setPluginName(String pluginName) {\r
this.pluginName = pluginName;\r
return this;\r
return description;\r
}\r
\r
+ /**\r
+ * Sets the rule description\r
+ */\r
+ public Rule setDescription(String description) {\r
+ this.description = StringUtils.strip(description);\r
+ return this;\r
+ }\r
+\r
public Boolean isEnabled() {\r
return enabled;\r
}\r
return this;\r
}\r
\r
- /**\r
- * Sets the rule description\r
- */\r
- public Rule setDescription(String description) {\r
- this.description = StringUtils.strip(description);\r
- return this;\r
- }\r
-\r
public List<RuleParam> getParams() {\r
return params;\r
}\r
\r
public RuleParam createParameter() {\r
RuleParam parameter = new RuleParam()\r
- .setRule(this);\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
}\r
Rule other = (Rule) obj;\r
return new EqualsBuilder()\r
- .append(pluginName, other.getPluginName())\r
+ .append(pluginName, other.getRepositoryKey())\r
.append(key, other.getKey())\r
.isEquals();\r
}\r