aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws-client/src
diff options
context:
space:
mode:
authorGodin <mandrikov@gmail.com>2010-12-06 18:47:39 +0000
committerGodin <mandrikov@gmail.com>2010-12-06 18:47:39 +0000
commit94df7f69d0d536cc32bb5fd8bbf445cd0ac552fc (patch)
tree5b478a972d2659909de786a4fd9e1c84e65faec0 /sonar-ws-client/src
parent3d4fc89dcb178c5f7188dd34f05fee580bc3906f (diff)
downloadsonarqube-94df7f69d0d536cc32bb5fd8bbf445cd0ac552fc.tar.gz
sonarqube-94df7f69d0d536cc32bb5fd8bbf445cd0ac552fc.zip
SONAR-1829: Rename the term "Priority" by "Severity" for rules in sonar-ws-client
Diffstat (limited to 'sonar-ws-client/src')
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java55
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java72
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java28
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java31
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java2
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java2
-rw-r--r--sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java14
7 files changed, 166 insertions, 38 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java
index 22036b279e0..ca9d1879206 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java
@@ -37,8 +37,12 @@ public class Measure extends Model {
private String ruleKey;
private String ruleName;
+ private String ruleSeverity;
+
+ /**
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
+ */
private String ruleCategory;
- private String rulePriority;
public String getMetricKey() {
return metricKey;
@@ -63,7 +67,7 @@ public class Measure extends Model {
}
public Integer getIntValue() {
- if (value==null) {
+ if (value == null) {
return null;
}
return value.intValue();
@@ -79,7 +83,7 @@ public class Measure extends Model {
}
public String getFormattedValue(String defaultValue) {
- if (formattedValue==null) {
+ if (formattedValue == null) {
return defaultValue;
}
return formattedValue;
@@ -94,15 +98,15 @@ public class Measure extends Model {
return data;
}
- public Map<String,String> getDataAsMap() {
+ public Map<String, String> getDataAsMap() {
return getDataAsMap(",");
}
- public Map<String,String> getDataAsMap(String separator) {
- if (data==null) {
+ public Map<String, String> getDataAsMap(String separator) {
+ if (data == null) {
return null;
}
- Map<String,String> map = new LinkedHashMap<String,String>();
+ Map<String, String> map = new LinkedHashMap<String, String>();
String[] parts = data.split(separator);
for (String part : parts) {
String[] kv = part.split("=");
@@ -152,21 +156,52 @@ public class Measure extends Model {
return this;
}
+ /**
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
+ */
+ @Deprecated
public String getRuleCategory() {
return ruleCategory;
}
+ /**
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
+ */
+ @Deprecated
public Measure setRuleCategory(String ruleCategory) {
this.ruleCategory = ruleCategory;
return this;
}
+ /**
+ * @since 2.5
+ */
+ public Measure setRuleSeverity(String ruleSeverity) {
+ this.ruleSeverity = ruleSeverity;
+ return this;
+ }
+
+ /**
+ * @since 2.5
+ */
+ public String getRuleSeverity() {
+ return ruleSeverity;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getRuleSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public String getRulePriority() {
- return rulePriority;
+ return ruleSeverity;
}
+ /**
+ * @deprecated since 2.5 use {@link #setRuleSeverity(String)} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public Measure setRulePriority(String rulePriority) {
- this.rulePriority = rulePriority;
+ this.ruleSeverity = rulePriority;
return this;
}
@@ -202,7 +237,7 @@ public class Measure extends Model {
.append(", ruleKey='").append(ruleKey).append('\'')
.append(", ruleName='").append(ruleName).append('\'')
.append(", ruleCategory='").append(ruleCategory).append('\'')
- .append(", rulePriority='").append(rulePriority).append('\'')
+ .append(", rulePriority='").append(ruleSeverity).append('\'')
.append('}').toString();
}
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java
index 8836b9f2bb0..7c9955d3b3f 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java
@@ -31,13 +31,18 @@ public class ResourceQuery extends Query<Resource> {
private String[] qualifiers;
private String[] metrics;
private String[] rules;
+
+ /**
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
+ */
private String[] ruleCategories;
- private String[] rulePriorities;
+
+ private String[] ruleSeverities;
private String[] characteristicKeys;
private String model;
private boolean excludeRules = true;
private boolean excludeRuleCategories = true;
- private boolean excludeRulePriorities = true;
+ private boolean excludeRuleSeverities = true;
private Boolean includeTrends = null;
private Boolean verbose = Boolean.FALSE;
@@ -80,11 +85,10 @@ public class ResourceQuery extends Query<Resource> {
}
public ResourceQuery setCharacteristicKeys(String model, String... keys) {
- this.model=model;
+ this.model = model;
this.characteristicKeys = keys;
return this;
}
-
public Integer getLimit() {
return limit;
@@ -132,12 +136,17 @@ public class ResourceQuery extends Query<Resource> {
return this;
}
+ /**
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
+ */
+ @Deprecated
public String[] getRuleCategories() {
return ruleCategories;
}
/**
* @param ruleCategories values: Maintainability, Usability, Reliability, Efficiency, Portability
+ * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
*/
public ResourceQuery setRuleCategories(String... ruleCategories) {
this.ruleCategories = ruleCategories;
@@ -145,17 +154,37 @@ public class ResourceQuery extends Query<Resource> {
return this;
}
+ /**
+ * @since 2.5
+ */
+ public String[] getRuleSeverities() {
+ return ruleSeverities;
+ }
+
+ /**
+ * @since 2.5
+ * @param ruleSeverities values: BLOCKER, CRITICAL, MAJOR, MINOR, INFO
+ */
+ public ResourceQuery setRuleSeverities(String... ruleSeverities) {
+ this.ruleSeverities = ruleSeverities;
+ this.excludeRuleSeverities = false;
+ return this;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getRuleSeverities()} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public String[] getRulePriorities() {
- return rulePriorities;
+ return ruleSeverities;
}
/**
- * @param rulePriorities values: BLOCKER, CRITICAL, MAJOR, MINOR, INFO
+ * @deprecated since 2.5 use {@link #setRuleSeverities(String...)} instead. See http://jira.codehaus.org/browse/SONAR-1829
*/
+ @Deprecated
public ResourceQuery setRulePriorities(String... rulePriorities) {
- this.rulePriorities = rulePriorities;
- this.excludeRulePriorities = false;
- return this;
+ return setRuleSeverities(rulePriorities);
}
public boolean isExcludeRules() {
@@ -176,12 +205,31 @@ public class ResourceQuery extends Query<Resource> {
return this;
}
+ /**
+ * @since 2.5
+ */
+ public boolean isExcludeRuleSeverities() {
+ return excludeRuleSeverities;
+ }
+
+ public void setExcludeRuleSeverities(boolean excludeRuleSeverities) {
+ this.excludeRuleSeverities = excludeRuleSeverities;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #isExcludeRuleSeverities()} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public boolean isExcludeRulePriorities() {
- return excludeRulePriorities;
+ return excludeRuleSeverities;
}
+ /**
+ * @deprecated since 2.5 use {@link #setExcludeRuleSeverities(boolean)} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public ResourceQuery setExcludeRulePriorities(boolean excludeRulePriorities) {
- this.excludeRulePriorities = excludeRulePriorities;
+ this.excludeRuleSeverities = excludeRulePriorities;
return this;
}
@@ -215,7 +263,7 @@ public class ResourceQuery extends Query<Resource> {
appendUrlParameter(url, "limit", limit);
appendRuleField(url, "rules", excludeRules, rules);
appendRuleField(url, "rule_categories", excludeRuleCategories, ruleCategories);
- appendRuleField(url, "rule_priorities", excludeRulePriorities, rulePriorities);
+ appendRuleField(url, "rule_priorities", excludeRuleSeverities, ruleSeverities);
appendUrlParameter(url, "includetrends", includeTrends);
appendUrlParameter(url, "model", model);
appendUrlParameter(url, "characteristics", characteristicKeys);
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java
index 5b1bdbeac25..ff0c3f22ce9 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Violation.java
@@ -24,7 +24,7 @@ import java.util.Date;
public class Violation extends Model {
private String message = null;
- private String priority = null;
+ private String severity = null;
private Integer line = null;
private String ruleKey = null;
private String ruleName = null;
@@ -42,12 +42,34 @@ public class Violation extends Model {
this.message = message;
}
+ /**
+ * @since 2.5
+ */
+ public String getSeverity() {
+ return severity;
+ }
+
+ /**
+ * @since 2.5
+ */
+ public void setSeverity(String severity) {
+ this.severity = severity;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public String getPriority() {
- return priority;
+ return severity;
}
+ /**
+ * @deprecated since 2.5 use {@link #setSeverity(String)} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public void setPriority(String priority) {
- this.priority = priority;
+ this.severity = priority;
}
public Integer getLine() {
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java
index 67bc4409546..92fe1f9d306 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java
@@ -26,7 +26,7 @@ public class ViolationQuery extends Query<Violation> {
private String[] qualifiers;
private String[] ruleKeys;
private String[] categories;
- private String[] priorities;
+ private String[] severities;
private int depth = 0;
private String resourceKeyOrId;
@@ -70,12 +70,35 @@ public class ViolationQuery extends Query<Violation> {
return this;
}
+ /**
+ * @since 2.5
+ */
+ public String[] getSeverities() {
+ return severities;
+ }
+
+ /**
+ * @since 2.5
+ */
+ public ViolationQuery setSeverities(String... severities) {
+ this.severities = severities;
+ return this;
+ }
+
+ /**
+ * @deprecated since 2.5 use {@link #getSeverities()} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public String[] getPriorities() {
- return priorities;
+ return severities;
}
+ /**
+ * @deprecated since 2.5 use {@link #setSeverities(String...)} instead. See http://jira.codehaus.org/browse/SONAR-1829
+ */
+ @Deprecated
public ViolationQuery setPriorities(String... priorities) {
- this.priorities = priorities;
+ this.severities = priorities;
return this;
}
@@ -102,7 +125,7 @@ public class ViolationQuery extends Query<Violation> {
append(url, "qualifiers", qualifiers);
append(url, "rules", ruleKeys);
append(url, "categories", categories);
- append(url, "priorities", priorities);
+ append(url, "priorities", severities);
return url.toString();
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java
index b0a001ee372..24c5f0d687c 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java
@@ -83,7 +83,7 @@ public class ResourceUnmarshaller extends AbstractUnmarshaller<Resource> {
.setRuleKey(JsonUtils.getString(json, "rule_key"))
.setRuleName(JsonUtils.getString(json, "rule_name"))
.setRuleCategory(JsonUtils.getString(json, "rule_category"))
- .setRulePriority(JsonUtils.getString(json, "rule_priority"))
+ .setRuleSeverity(JsonUtils.getString(json, "rule_priority"))
.setCharacteristicKey(JsonUtils.getString(json, "ctic_key"))
.setCharacteristicName(JsonUtils.getString(json, "ctic_name"));
return measure;
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java
index 1d0154df2d8..258e5938570 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshaller.java
@@ -29,7 +29,7 @@ public class ViolationUnmarshaller extends AbstractUnmarshaller<Violation> {
Violation violation = new Violation();
violation.setMessage(JsonUtils.getString(json, "message"));
violation.setLine(JsonUtils.getInteger(json, "line"));
- violation.setPriority(JsonUtils.getString(json, "priority"));
+ violation.setSeverity(JsonUtils.getString(json, "priority"));
violation.setCreatedAt(JsonUtils.getDateTime(json, "createdAt"));
JSONObject rule = (JSONObject) json.get("rule");
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java
index 7eb1e1aaf7b..4f2feefd4a5 100644
--- a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java
+++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ViolationUnmarshallerTest.java
@@ -19,12 +19,6 @@
*/
package org.sonar.wsclient.unmarshallers;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.hamcrest.core.IsNot.not;
-import static org.junit.Assert.assertThat;
-
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.sonar.wsclient.services.Violation;
@@ -32,6 +26,12 @@ import org.sonar.wsclient.services.Violation;
import java.io.IOException;
import java.util.List;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.hamcrest.core.IsNot.not;
+import static org.junit.Assert.assertThat;
+
public class ViolationUnmarshallerTest {
@Test
@@ -46,7 +46,7 @@ public class ViolationUnmarshallerTest {
assertThat(violation.getMessage(), is("throw java.lang.Exception"));
assertThat(violation.getLine(), is(97));
assertThat(violation.getCreatedAt(), notNullValue());
- assertThat(violation.getPriority(), is("MAJOR"));
+ assertThat(violation.getSeverity(), is("MAJOR"));
assertThat(violation.getRuleKey(), is("pmd:SignatureDeclareThrowsException"));
assertThat(violation.getRuleName(), is("Signature Declare Throws Exception"));
assertThat(violation.getResourceKey(),