aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@gmail.com>2013-07-05 11:44:21 +0200
committerJulien Lancelot <julien.lancelot@gmail.com>2013-07-05 11:44:21 +0200
commit0c6ff8b4aa9d0a37fe3190acc07225f4f410ec18 (patch)
tree7a30b785820de92e4aa8c1a5dc9e4bb0ef4d7023
parent84c173736bd43b7b7aa546e6b84d2d52089c68c1 (diff)
downloadsonarqube-0c6ff8b4aa9d0a37fe3190acc07225f4f410ec18.tar.gz
sonarqube-0c6ff8b4aa9d0a37fe3190acc07225f4f410ec18.zip
Fix quality flaws
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java8
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/Dependency.java10
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/Event.java6
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java3
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineQuery.java3
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/ViolationQuery.java3
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java12
7 files changed, 33 insertions, 12 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java
index 27e80bb335e..f6c8e398bdc 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java
@@ -19,6 +19,8 @@
*/
package org.sonar.wsclient.services;
+import javax.annotation.Nullable;
+
import java.util.Date;
/**
@@ -110,7 +112,7 @@ public abstract class AbstractQuery<M extends Model> {
.append("&");
}
- protected static void appendUrlParameter(StringBuilder url, String paramKey, Object paramValue) {
+ protected static void appendUrlParameter(StringBuilder url, String paramKey, @Nullable Object paramValue) {
if (paramValue != null) {
url.append(paramKey)
.append('=')
@@ -119,7 +121,7 @@ public abstract class AbstractQuery<M extends Model> {
}
}
- protected static void appendUrlParameter(StringBuilder url, String paramKey, Object[] paramValues) {
+ protected static void appendUrlParameter(StringBuilder url, String paramKey, @Nullable Object[] paramValues) {
if (paramValues != null) {
url.append(paramKey).append('=');
for (int index = 0; index < paramValues.length; index++) {
@@ -134,7 +136,7 @@ public abstract class AbstractQuery<M extends Model> {
}
}
- protected static void appendUrlParameter(StringBuilder url, String paramKey, Date paramValue, boolean includeTime) {
+ protected static void appendUrlParameter(StringBuilder url, String paramKey, @Nullable Date paramValue, boolean includeTime) {
if (paramValue != null) {
String format = (includeTime ? "yyyy-MM-dd'T'HH:mm:ssZ" : "yyyy-MM-dd");
url.append(paramKey)
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Dependency.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Dependency.java
index a844ec6eee7..da47533fe47 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Dependency.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Dependency.java
@@ -25,10 +25,10 @@ import javax.annotation.Nullable;
public class Dependency extends Model {
private String id;
- private long fromId;
- private long toId;
+ private Long fromId;
+ private Long toId;
private String usage;
- private int weight;
+ private Integer weight;
private String fromKey;
private String fromName;
private String fromQualifier;
@@ -50,7 +50,7 @@ public class Dependency extends Model {
return fromId;
}
- public Dependency setFromId(@Nullable long fromId) {
+ public Dependency setFromId(@Nullable Long fromId) {
this.fromId = fromId;
return this;
}
@@ -59,7 +59,7 @@ public class Dependency extends Model {
return toId;
}
- public Dependency setToId(@Nullable long toId) {
+ public Dependency setToId(@Nullable Long toId) {
this.toId = toId;
return this;
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Event.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Event.java
index 6809bcf366b..8aaa15e24b9 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Event.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Event.java
@@ -43,6 +43,7 @@ public class Event extends Model {
this.id = id;
return this;
}
+
@CheckForNull
public String getName() {
return name;
@@ -52,6 +53,7 @@ public class Event extends Model {
this.name = name;
return this;
}
+
@CheckForNull
public String getCategory() {
return category;
@@ -61,6 +63,7 @@ public class Event extends Model {
this.category = category;
return this;
}
+
@CheckForNull
public String getDescription() {
return description;
@@ -70,6 +73,7 @@ public class Event extends Model {
this.description = description;
return this;
}
+
@CheckForNull
public Date getDate() {
return date;
@@ -79,6 +83,7 @@ public class Event extends Model {
this.date = date;
return this;
}
+
@CheckForNull
public String getResourceKey() {
return resourceKey;
@@ -88,6 +93,7 @@ public class Event extends Model {
this.resourceKey = resourceKey;
return this;
}
+
@CheckForNull
public String getData() {
return data;
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 7ae851fbb4a..8233c865523 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
@@ -302,6 +302,9 @@ public class ResourceQuery extends Query<Resource> {
}
public static ResourceQuery createForResource(Resource resource, String... metricKeys) {
+ if (resource.getId() == null) {
+ throw new IllegalArgumentException("id must be set");
+ }
return new ResourceQuery(resource.getId().toString())
.setMetrics(metricKeys);
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineQuery.java
index b540ef6fa08..a4dc5cea07f 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineQuery.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineQuery.java
@@ -96,6 +96,9 @@ public class TimeMachineQuery extends Query<TimeMachine> {
}
public static TimeMachineQuery createForMetrics(Resource resource, String... metricKeys) {
+ if (resource.getId() == null) {
+ throw new IllegalArgumentException("id must be set");
+ }
return new TimeMachineQuery(resource.getId().toString()).setMetrics(metricKeys);
}
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 c9f20f9ec9d..efb07cb1ff7 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
@@ -133,6 +133,9 @@ public class ViolationQuery extends Query<Violation> {
}
public static ViolationQuery createForResource(Resource resource) {
+ if (resource.getId() == null) {
+ throw new IllegalArgumentException("id must be set");
+ }
return new ViolationQuery(resource.getId().toString());
}
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java
index 7730105c843..68bdfc8066a 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java
@@ -24,19 +24,23 @@ import org.sonar.wsclient.services.TimeMachineCell;
import org.sonar.wsclient.services.TimeMachineColumn;
import org.sonar.wsclient.services.WSUtils;
-import javax.annotation.Nullable;
-
public class TimeMachineUnmarshaller extends AbstractUnmarshaller<TimeMachine> {
@Override
protected TimeMachine parse(Object json) {
WSUtils utils = WSUtils.getINSTANCE();
Object cols = utils.getField(json, "cols");
+ if (cols == null) {
+ throw new IllegalArgumentException("cols must be set");
+ }
Object cells = utils.getField(json, "cells");
+ if (cells == null) {
+ throw new IllegalArgumentException("cells must be set");
+ }
return new TimeMachine(toColumns(cols), toCells(cells));
}
- private TimeMachineColumn[] toColumns(@Nullable Object cols) {
+ private TimeMachineColumn[] toColumns(Object cols) {
WSUtils utils = WSUtils.getINSTANCE();
int size = utils.getArraySize(cols);
TimeMachineColumn[] result = new TimeMachineColumn[size];
@@ -47,7 +51,7 @@ public class TimeMachineUnmarshaller extends AbstractUnmarshaller<TimeMachine> {
return result;
}
- private TimeMachineCell[] toCells(@Nullable Object cells) {
+ private TimeMachineCell[] toCells(Object cells) {
WSUtils utils = WSUtils.getINSTANCE();
int size = utils.getArraySize(cells);
TimeMachineCell[] result = new TimeMachineCell[size];