aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java13
-rw-r--r--plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java2
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecorator.java2
-rw-r--r--plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/Dsm.java2
-rw-r--r--plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java4
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java12
-rw-r--r--sonar-server/src/main/java/org/sonar/server/util/RubyUtils.java2
-rw-r--r--sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java2
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java4
-rw-r--r--sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java2
12 files changed, 31 insertions, 28 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java
index 8171683a356..e521d627380 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/DefaultResourceTypes.java
@@ -29,6 +29,9 @@ import org.sonar.api.resources.ResourceTypeTree;
@InstantiationStrategy(InstantiationStrategy.PER_BATCH)
public final class DefaultResourceTypes extends ExtensionProvider implements BatchExtension, ServerExtension {
+
+ private static final String SUPPORTS_MEASURE_FILTERS = "supportsMeasureFilters";
+
@Override
public ResourceTypeTree provide() {
return ResourceTypeTree.builder()
@@ -38,30 +41,30 @@ public final class DefaultResourceTypes extends ExtensionProvider implements Bat
.setProperty("modifiable_history", true)
.setProperty("hasRolePolicy", true)
.setProperty("updatable_key", true)
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.setProperty("comparable", true)
.setProperty("configurable", true)
.build())
.addType(ResourceType.builder(Qualifiers.MODULE)
.setProperty("updatable_key", true)
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.setProperty("configurable", true)
.build())
.addType(ResourceType.builder(Qualifiers.DIRECTORY)
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.build())
.addType(ResourceType.builder(Qualifiers.PACKAGE)
.build())
.addType(ResourceType.builder(Qualifiers.FILE)
.hasSourceCode()
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.build())
.addType(ResourceType.builder(Qualifiers.CLASS)
.hasSourceCode()
.build())
.addType(ResourceType.builder(Qualifiers.UNIT_TEST_FILE)
.hasSourceCode()
- .setProperty("supportsMeasureFilters", true)
+ .setProperty(SUPPORTS_MEASURE_FILTERS, true)
.build())
.addRelations(Qualifiers.PROJECT, Qualifiers.MODULE)
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java
index 58b7ba469c7..6b8f9f191fb 100644
--- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java
+++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/NewCoverageAggregator.java
@@ -52,7 +52,7 @@ public final class NewCoverageAggregator implements Decorator {
public void decorate(Resource resource, DecoratorContext context) {
if (shouldDecorate(resource)) {
- int maxPeriods = (Qualifiers.isView(resource, true) ? 3 : 5);
+ int maxPeriods = Qualifiers.isView(resource, true) ? 3 : 5;
aggregate(context, CoreMetrics.NEW_LINES_TO_COVER, maxPeriods);
aggregate(context, CoreMetrics.NEW_UNCOVERED_LINES, maxPeriods);
aggregate(context, CoreMetrics.NEW_CONDITIONS_TO_COVER, maxPeriods);
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecorator.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecorator.java
index 7b0ee4a1949..b722957d1c2 100644
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecorator.java
+++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/batch/SuspectLcom4DensityDecorator.java
@@ -73,7 +73,7 @@ public class SuspectLcom4DensityDecorator implements Decorator {
}
if (hasLcom4 && totalFiles > 0) {
- context.saveMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY, (total / totalFiles));
+ context.saveMeasure(CoreMetrics.SUSPECT_LCOM4_DENSITY, total / totalFiles);
}
}
diff --git a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/Dsm.java b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/Dsm.java
index 9539a9c96ce..1dad1fa06c5 100644
--- a/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/Dsm.java
+++ b/plugins/sonar-design-plugin/src/main/java/org/sonar/plugins/design/ui/page/client/Dsm.java
@@ -289,7 +289,7 @@ public class Dsm extends Composite {
private Label createNonDiagonalCell(final int row, final int col, int weight) {
Label cell;
- cell = buildCell(row, col, weight, (col > row ? GRID_CELL_TOP_RIGHT : GRID_CELL_BOTTOM_LEFT));
+ cell = buildCell(row, col, weight, col > row ? GRID_CELL_TOP_RIGHT : GRID_CELL_BOTTOM_LEFT);
if (weight > 0) {
String tooltip = data.get(col).getName() + " -> " + data.get(row).getName() + " (" + weight + "). " + Dictionary.getDictionary("l10n").get("design.cellTooltip");
diff --git a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java
index f1e532514ea..4dea1968071 100644
--- a/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java
+++ b/plugins/sonar-maven-batch-plugin/src/main/java/org/sonar/plugins/maven/DefaultMavenPluginExecutor.java
@@ -57,7 +57,7 @@ public class DefaultMavenPluginExecutor implements MavenPluginExecutor {
MavenPlugin plugin = MavenPlugin.getPlugin(project.getPom(), handler.getGroupId(), handler.getArtifactId());
execute(project,
fs,
- getGoal(handler.getGroupId(), handler.getArtifactId(), (plugin != null && plugin.getPlugin() != null ? plugin.getPlugin().getVersion() : null), goal));
+ getGoal(handler.getGroupId(), handler.getArtifactId(), plugin != null && plugin.getPlugin() != null ? plugin.getPlugin().getVersion() : null, goal));
}
return handler;
}
@@ -82,7 +82,7 @@ public class DefaultMavenPluginExecutor implements MavenPluginExecutor {
}
static String getGoal(String groupId, String artifactId, @Nullable String version, String goal) {
- String defaultVersion = (version == null ? "" : version);
+ String defaultVersion = version == null ? "" : version;
return new StringBuilder()
.append(groupId).append(":")
.append(artifactId).append(":")
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java
index 2bd49827409..cb1324f7df6 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/config/PropertyDefinition.java
@@ -497,7 +497,7 @@ public final class PropertyDefinition implements BatchExtension, ServerExtension
Preconditions.checkArgument(!Strings.isNullOrEmpty(key), "Key must be set");
fixType(key, type);
Preconditions.checkArgument(onQualifiers.isEmpty() || onlyOnQualifiers.isEmpty(), "Cannot define both onQualifiers and onlyOnQualifiers");
- Preconditions.checkArgument((!hidden || (onQualifiers.isEmpty()) && onlyOnQualifiers.isEmpty()), "Cannot be hidden and defining qualifiers on which to display");
+ Preconditions.checkArgument(!hidden || (onQualifiers.isEmpty() && onlyOnQualifiers.isEmpty()), "Cannot be hidden and defining qualifiers on which to display");
if (hidden) {
global = false;
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
index 9826894fc23..278050f32da 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
@@ -164,17 +164,17 @@ public class IssueQuery {
@CheckForNull
public Date createdAfter() {
- return (createdAfter == null ? null : new Date(createdAfter.getTime()));
+ return createdAfter == null ? null : new Date(createdAfter.getTime());
}
@CheckForNull
public Date createdAt() {
- return (createdAt == null ? null : new Date(createdAt.getTime()));
+ return createdAt == null ? null : new Date(createdAt.getTime());
}
@CheckForNull
public Date createdBefore() {
- return (createdBefore == null ? null : new Date(createdBefore.getTime()));
+ return createdBefore == null ? null : new Date(createdBefore.getTime());
}
@CheckForNull
@@ -316,17 +316,17 @@ public class IssueQuery {
}
public Builder createdAt(@Nullable Date d) {
- this.createdAt = (d == null ? null : new Date(d.getTime()));
+ this.createdAt = d == null ? null : new Date(d.getTime());
return this;
}
public Builder createdAfter(@Nullable Date d) {
- this.createdAfter = (d == null ? null : new Date(d.getTime()));
+ this.createdAfter = d == null ? null : new Date(d.getTime());
return this;
}
public Builder createdBefore(@Nullable Date d) {
- this.createdBefore = (d == null ? null : new Date(d.getTime()));
+ this.createdBefore = d == null ? null : new Date(d.getTime());
return this;
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
index 24fd2c8cf50..2a5a0c63640 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/KeyValueFormat.java
@@ -106,7 +106,7 @@ public final class KeyValueFormat {
@Override
String format(Integer s) {
- return (s == null ? "" : String.valueOf(s));
+ return s == null ? "" : String.valueOf(s);
}
@Override
@@ -127,7 +127,7 @@ public final class KeyValueFormat {
@Override
String format(RulePriority s) {
- return (s == null ? "" : s.toString());
+ return s == null ? "" : s.toString();
}
@Override
@@ -148,7 +148,7 @@ public final class KeyValueFormat {
@Override
String format(Double d) {
- return (d == null ? "" : String.valueOf(d));
+ return d == null ? "" : String.valueOf(d);
}
@Override
@@ -178,7 +178,7 @@ public final class KeyValueFormat {
@Override
String format(Date d) {
- return (d == null ? "" : dateFormat.format(d));
+ return d == null ? "" : dateFormat.format(d);
}
@Override
@@ -220,7 +220,7 @@ public final class KeyValueFormat {
for (String pair : pairs) {
String[] keyValue = StringUtils.split(pair, FIELD_SEPARATOR);
String key = keyValue[0];
- String value = (keyValue.length == 2 ? keyValue[1] : "");
+ String value = keyValue.length == 2 ? keyValue[1] : "";
map.put(keyConverter.parse(key), valueConverter.parse(value));
}
}
@@ -294,7 +294,7 @@ public final class KeyValueFormat {
for (String pair : pairs) {
String[] keyValue = StringUtils.split(pair, FIELD_SEPARATOR);
String key = keyValue[0];
- String value = (keyValue.length == 2 ? keyValue[1] : "0");
+ String value = keyValue.length == 2 ? keyValue[1] : "0";
multiset.add(keyConverter.parse(key), new IntegerConverter().parse(value));
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/util/RubyUtils.java b/sonar-server/src/main/java/org/sonar/server/util/RubyUtils.java
index 78c17bb800e..2e46eecb29a 100644
--- a/sonar-server/src/main/java/org/sonar/server/util/RubyUtils.java
+++ b/sonar-server/src/main/java/org/sonar/server/util/RubyUtils.java
@@ -142,7 +142,7 @@ public class RubyUtils {
return ((Integer)o).longValue();
}
if (o instanceof Long) {
- return ((Long) o);
+ return (Long) o;
}
if (o instanceof String) {
if (StringUtils.isBlank((String)o)) {
diff --git a/sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java b/sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java
index 6fe42851fa3..6aa9b7e14a7 100644
--- a/sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java
+++ b/sonar-squid/src/main/java/org/sonar/squid/api/SourceCode.java
@@ -276,7 +276,7 @@ public abstract class SourceCode implements Measurable, Comparable<SourceCode> {
}
public boolean hasChildren() {
- return children != null && children.size() != 0;
+ return children != null && !children.isEmpty();
}
public boolean hasAmongParents(SourceCode expectedParent) {
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 f6c8e398bdc..979e43b51c2 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
@@ -75,7 +75,7 @@ public abstract class AbstractQuery<M extends Model> {
* @since 2.10
*/
public final AbstractQuery<M> setTimeoutMilliseconds(int i) {
- this.timeoutMilliseconds = (i < 0 ? 0 : i);
+ this.timeoutMilliseconds = i<0 ? 0 : i;
return this;
}
@@ -138,7 +138,7 @@ public abstract class AbstractQuery<M extends Model> {
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");
+ String format = includeTime ? "yyyy-MM-dd'T'HH:mm:ssZ" : "yyyy-MM-dd";
url.append(paramKey)
.append('=')
.append(encode(WSUtils.getINSTANCE().format(paramValue, format)))
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java
index 943974d2c3e..c1825cfb03b 100644
--- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java
+++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java
@@ -111,7 +111,7 @@ public final class JsonUtils {
return dateFormat.parse(value);
} catch (ParseException e) {
- throw new RuntimeException(e);
+ throw new IllegalArgumentException("Fail to parse date property '" + field + "': " + format, e);
}
}
return null;