diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-07-05 13:45:33 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-07-05 13:45:33 +0200 |
commit | f12b3775d4368a084eb8f1c9099f82ee06bc1e15 (patch) | |
tree | abd3401c6e06d2b2b58dd51176f59acb5c67b6db /sonar-ws-client/src/main/java/org | |
parent | 8ffca6c7304e7082b207512e54e55e9d0be3dd68 (diff) | |
download | sonarqube-f12b3775d4368a084eb8f1c9099f82ee06bc1e15.tar.gz sonarqube-f12b3775d4368a084eb8f1c9099f82ee06bc1e15.zip |
Fix quality flaws
Diffstat (limited to 'sonar-ws-client/src/main/java/org')
9 files changed, 46 insertions, 32 deletions
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 da47533fe47..66b2a9a67d7 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 @@ -41,12 +41,13 @@ public class Dependency extends Model { return id; } - public Dependency setId(String id) { + public Dependency setId(@Nullable String id) { this.id = id; return this; } - public long getFromId() { + @CheckForNull + public Long getFromId() { return fromId; } @@ -55,7 +56,8 @@ public class Dependency extends Model { return this; } - public long getToId() { + @CheckForNull + public Long getToId() { return toId; } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTree.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTree.java index e9e8d7480cb..f7ccfda13d6 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTree.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTree.java @@ -36,7 +36,7 @@ public class DependencyTree extends Model { private String resourceScope; private String resourceQualifier; private String resourceVersion; - private int weight; + private Integer weight; private List<DependencyTree> to; @CheckForNull @@ -112,11 +112,12 @@ public class DependencyTree extends Model { return this; } - public int getWeight() { + @CheckForNull + public Integer getWeight() { return weight; } - public DependencyTree setWeight(@Nullable int weight) { + public DependencyTree setWeight(@Nullable Integer weight) { this.weight = weight; return this; } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java index b08f3e7d749..984fd499cb4 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java @@ -29,7 +29,7 @@ import java.util.Date; */ public class ManualMeasure extends Model { - private long id; + private Long id; private String metricKey; private String resourceKey; private Double value; @@ -43,14 +43,15 @@ public class ManualMeasure extends Model { } @CheckForNull - public long getId() { + public Long getId() { return id; } - public ManualMeasure setId(@Nullable long id) { + public ManualMeasure setId(@Nullable Long id) { this.id = id; return this; } + @CheckForNull public String getMetricKey() { return metricKey; @@ -60,6 +61,7 @@ public class ManualMeasure extends Model { this.metricKey = metricKey; return this; } + @CheckForNull public Double getValue() { return value; @@ -69,6 +71,7 @@ public class ManualMeasure extends Model { this.value = value; return this; } + @CheckForNull public String getTextValue() { return textValue; @@ -78,6 +81,7 @@ public class ManualMeasure extends Model { this.textValue = textValue; return this; } + @CheckForNull public Date getCreatedAt() { return createdAt; @@ -87,6 +91,7 @@ public class ManualMeasure extends Model { this.createdAt = createdAt; return this; } + @CheckForNull public Date getUpdatedAt() { return updatedAt; @@ -96,6 +101,7 @@ public class ManualMeasure extends Model { this.updatedAt = updatedAt; return this; } + @CheckForNull public String getUserLogin() { return userLogin; @@ -105,6 +111,7 @@ public class ManualMeasure extends Model { this.userLogin = userLogin; return this; } + @CheckForNull public String getUsername() { return username; @@ -114,6 +121,7 @@ public class ManualMeasure extends Model { this.username = username; return this; } + @CheckForNull public String getResourceKey() { return resourceKey; @@ -127,11 +135,11 @@ public class ManualMeasure extends Model { @Override public String toString() { return new StringBuilder().append("Measure{") - .append("id='").append(id).append('\'') - .append("resourceKey='").append(resourceKey).append('\'') - .append("metricKey='").append(metricKey).append('\'') - .append(", value=").append(value) - .append(", textValue='").append(textValue).append('\'') - .append('}').toString(); + .append("id='").append(id).append('\'') + .append("resourceKey='").append(resourceKey).append('\'') + .append("metricKey='").append(metricKey).append('\'') + .append(", value=").append(value) + .append(", textValue='").append(textValue).append('\'') + .append('}').toString(); } } diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Metric.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Metric.java index de636b6a186..804fbb274e1 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Metric.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Metric.java @@ -26,7 +26,7 @@ public class Metric extends Model { private String key; private String name; - private int direction; + private Integer direction; private String domain; private String description; private String type; @@ -54,11 +54,11 @@ public class Metric extends Model { } @CheckForNull - public int getDirection() { + public Integer getDirection() { return direction; } - public Metric setDirection(@Nullable int direction) { + public Metric setDirection(@Nullable Integer direction) { this.direction = direction; return this; } 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 8233c865523..778840f0236 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,10 +302,11 @@ public class ResourceQuery extends Query<Resource> { } public static ResourceQuery createForResource(Resource resource, String... metricKeys) { - if (resource.getId() == null) { + Integer id = resource.getId(); + if (id == null) { throw new IllegalArgumentException("id must be set"); } - return new ResourceQuery(resource.getId().toString()) + return new ResourceQuery(id.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 a4dc5cea07f..87c8d09de3d 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,10 +96,11 @@ public class TimeMachineQuery extends Query<TimeMachine> { } public static TimeMachineQuery createForMetrics(Resource resource, String... metricKeys) { - if (resource.getId() == null) { + Integer id = resource.getId(); + if (id == null) { throw new IllegalArgumentException("id must be set"); } - return new TimeMachineQuery(resource.getId().toString()).setMetrics(metricKeys); + return new TimeMachineQuery(id.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 efb07cb1ff7..ed5ab4bbe1d 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,10 +133,11 @@ public class ViolationQuery extends Query<Violation> { } public static ViolationQuery createForResource(Resource resource) { - if (resource.getId() == null) { + Integer id = resource.getId(); + if (id == null) { throw new IllegalArgumentException("id must be set"); } - return new ViolationQuery(resource.getId().toString()); + return new ViolationQuery(id.toString()); } public static ViolationQuery createForResource(String resourceIdOrKey) { diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java index a4c1afa1f55..a1b101844da 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java @@ -39,7 +39,6 @@ public class ManualMeasureUnmarshaller extends AbstractUnmarshaller<ManualMeasur .setUserLogin(utils.getString(json, "login")) .setUsername(utils.getString(json, "username")) .setValue(utils.getDouble(json, "val")) - .setTextValue(utils.getString(json, "text")) - ; + .setTextValue(utils.getString(json, "text")); } } 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 68bdfc8066a..a9b4951d25c 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 @@ -58,13 +58,14 @@ public class TimeMachineUnmarshaller extends AbstractUnmarshaller<TimeMachine> { for (int i = 0; i < size; i++) { Object cellJson = utils.getArrayElement(cells, i); Object valuesJson = utils.getField(cellJson, "v"); - - Object[] resultValues = new Object[utils.getArraySize(valuesJson)]; - for (int indexValue = 0; indexValue < utils.getArraySize(valuesJson); indexValue++) { - Object value = utils.getArrayElement(valuesJson, indexValue); - resultValues[indexValue] = value; + if (valuesJson != null) { + Object[] resultValues = new Object[utils.getArraySize(valuesJson)]; + for (int indexValue = 0; indexValue < utils.getArraySize(valuesJson); indexValue++) { + Object value = utils.getArrayElement(valuesJson, indexValue); + resultValues[indexValue] = value; + } + result[i] = new TimeMachineCell(utils.getDateTime(cellJson, "d"), resultValues); } - result[i] = new TimeMachineCell(utils.getDateTime(cellJson, "d"), resultValues); } return result; } |