diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-06-19 22:58:26 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-06-19 22:58:43 +0200 |
commit | 44447ed6b69b1497ed60cc4d610742a5d9987873 (patch) | |
tree | 8fd855775d044924a42cfa2e8b87d8453538f69d | |
parent | 48a077eea19bbe6c0c83dac028e1026bba74a09a (diff) | |
download | sonarqube-44447ed6b69b1497ed60cc4d610742a5d9987873.tar.gz sonarqube-44447ed6b69b1497ed60cc4d610742a5d9987873.zip |
Fix Q flaws
22 files changed, 87 insertions, 53 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java index a6270694417..1c169704270 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java +++ b/server/sonar-server/src/main/java/org/sonar/server/charts/deprecated/PieChart.java @@ -93,7 +93,7 @@ public class PieChart extends BaseChartWeb implements DeprecatedChart { private void configureDefaultColors() { PiePlot plot = (PiePlot) jfreechart.getPlot(); for (int i=0 ; i<COLORS.length ; i++) { - plot.setSectionPaint("" + i, COLORS[i]); + plot.setSectionPaint(Integer.toString(i), COLORS[i]); } } diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ClassLoaderUtils.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ClassLoaderUtils.java index 989c79561c5..bab34f21073 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ClassLoaderUtils.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ClassLoaderUtils.java @@ -19,15 +19,10 @@ */ package org.sonar.server.platform; -import com.google.common.base.*; +import com.google.common.base.Function; +import com.google.common.base.Predicate; +import com.google.common.base.Throwables; import com.google.common.collect.Lists; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.CharEncoding; -import org.apache.commons.lang.StringUtils; -import org.sonar.api.utils.log.Loggers; - -import javax.annotation.Nullable; - import java.io.File; import java.io.IOException; import java.net.URL; @@ -36,6 +31,11 @@ import java.util.Collection; import java.util.Enumeration; import java.util.jar.JarEntry; import java.util.jar.JarFile; +import javax.annotation.Nullable; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.CharEncoding; +import org.apache.commons.lang.StringUtils; +import org.sonar.api.utils.log.Loggers; /** * @since 3.0 diff --git a/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/FormulaDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/FormulaDecorator.java index 8b60efcaf19..8331347c988 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/FormulaDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/deprecated/decorator/FormulaDecorator.java @@ -19,18 +19,22 @@ */ package org.sonar.batch.deprecated.decorator; -import org.sonar.api.batch.*; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import org.sonar.api.batch.Decorator; +import org.sonar.api.batch.DecoratorContext; +import org.sonar.api.batch.DefaultFormulaContext; +import org.sonar.api.batch.DefaultFormulaData; +import org.sonar.api.batch.DependedUpon; +import org.sonar.api.batch.DependsUpon; import org.sonar.api.measures.FormulaData; import org.sonar.api.measures.Measure; import org.sonar.api.measures.Metric; import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.Set; - /** * A pre-implementation of a decorator using a simple calculation formula * @since 1.11 diff --git a/sonar-core/src/main/java/org/sonar/core/config/SecurityProperties.java b/sonar-core/src/main/java/org/sonar/core/config/SecurityProperties.java index e4678e69bc2..ec10843e3e9 100644 --- a/sonar-core/src/main/java/org/sonar/core/config/SecurityProperties.java +++ b/sonar-core/src/main/java/org/sonar/core/config/SecurityProperties.java @@ -36,7 +36,7 @@ class SecurityProperties { return ImmutableList.of( PropertyDefinition.builder(CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY) - .defaultValue("" + CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_DEAULT_VALUE) + .defaultValue(Boolean.toString(CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_DEAULT_VALUE)) .name("Allow users to sign up online") .description("Users can sign up online.") .type(PropertyType.BOOLEAN) @@ -51,7 +51,7 @@ class SecurityProperties { .build(), PropertyDefinition.builder(CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY) - .defaultValue("" + CoreProperties.CORE_FORCE_AUTHENTICATION_DEFAULT_VALUE) + .defaultValue(Boolean.toString(CoreProperties.CORE_FORCE_AUTHENTICATION_DEFAULT_VALUE)) .name("Force user authentication") .description("Forcing user authentication stops un-logged users to access SonarQube.") .type(PropertyType.BOOLEAN) diff --git a/sonar-core/src/main/java/org/sonar/core/issue/workflow/StateMachine.java b/sonar-core/src/main/java/org/sonar/core/issue/workflow/StateMachine.java index 15d0a39ccca..25e3686a715 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/workflow/StateMachine.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/workflow/StateMachine.java @@ -20,13 +20,16 @@ package org.sonar.core.issue.workflow; import com.google.common.base.Preconditions; -import com.google.common.collect.*; - -import javax.annotation.CheckForNull; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ListMultimap; +import com.google.common.collect.Sets; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; +import javax.annotation.CheckForNull; public class StateMachine { diff --git a/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java b/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java index aee97841880..6ef4df804f6 100644 --- a/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java +++ b/sonar-core/src/main/java/org/sonar/core/util/HttpsTrust.java @@ -19,12 +19,18 @@ */ package org.sonar.core.util; -import javax.net.ssl.*; import java.net.HttpURLConnection; import java.security.KeyManagementException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.security.cert.X509Certificate; +import javax.net.ssl.HostnameVerifier; +import javax.net.ssl.HttpsURLConnection; +import javax.net.ssl.SSLContext; +import javax.net.ssl.SSLSession; +import javax.net.ssl.SSLSocketFactory; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; /** * @since 4.0 diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractDivisionDecorator.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractDivisionDecorator.java index 82fa6e9fade..fb624c832c8 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractDivisionDecorator.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/AbstractDivisionDecorator.java @@ -88,7 +88,7 @@ public abstract class AbstractDivisionDecorator implements Decorator { protected double compute(Measure dividend, Measure divisor, boolean shouldResultBeInPercent) { double result = dividend.getValue() / divisor.getValue(); - return shouldResultBeInPercent ? result * 100 : result; + return shouldResultBeInPercent ? (result * 100) : result; } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java index 755eecc1d70..10989371fe3 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java @@ -76,7 +76,9 @@ public class ProjectDefinition { private static final char SEPARATOR = ','; - private File baseDir, workDir, buildDir; + private File baseDir; + private File workDir; + private File buildDir; private Map<String, String> properties = new HashMap<>(); private ProjectDefinition parent = null; private List<ProjectDefinition> subProjects = new ArrayList<>(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java index 07034bbfe56..4493449e62f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRule.java @@ -37,10 +37,13 @@ public class DefaultRule implements Rule { private final RuleKey key; private final Integer id; - private final String name, severity, description, internalKey, debtSubCharacteristic; + private final String name; + private final String severity; + private final String description; + private final String internalKey; + private final String debtSubCharacteristic; private final RuleStatus status; private final DebtRemediationFunction debtRemediationFunction; - private final Map<String, RuleParam> params; DefaultRule(NewRule newRule) { diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRuleParam.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRuleParam.java index cc1725013c9..44962e2f385 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRuleParam.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/DefaultRuleParam.java @@ -27,7 +27,8 @@ import javax.annotation.concurrent.Immutable; @Immutable class DefaultRuleParam implements RuleParam { - private final String key, description; + private final String key; + private final String description; DefaultRuleParam(NewRuleParam p) { this.key = p.key; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java index 593f859c695..3572315f472 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/internal/NewRule.java @@ -37,7 +37,11 @@ public class NewRule { final RuleKey key; Integer id; - String name, description, severity = DEFAULT_SEVERITY, internalKey, debtSubCharacteristic; + String name; + String description; + String severity = DEFAULT_SEVERITY; + String internalKey; + String debtSubCharacteristic; DebtRemediationFunction debtRemediationFunction; RuleStatus status = RuleStatus.defaultStatus(); Map<String, NewRuleParam> params = new HashMap<>(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java b/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java index 15eb2f256c2..f07a7ad30ee 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java @@ -147,7 +147,7 @@ public class ChartParameters { * @return width */ public int getWidth() { - int width = Integer.parseInt(getValue(PARAM_WIDTH, "" + DEFAULT_WIDTH, false)); + int width = Integer.parseInt(getValue(PARAM_WIDTH, Integer.toString(DEFAULT_WIDTH), false)); return Math.min(width, MAX_WIDTH); } @@ -157,7 +157,7 @@ public class ChartParameters { * @return height */ public int getHeight() { - int height = Integer.parseInt(getValue(PARAM_HEIGHT, "" + DEFAULT_HEIGHT, false)); + int height = Integer.parseInt(getValue(PARAM_HEIGHT, Integer.toString(DEFAULT_HEIGHT), false)); return Math.min(height, MAX_HEIGHT); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java index 3d849817425..554e25db743 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java @@ -19,19 +19,19 @@ */ package org.sonar.api.database.model; +import java.io.Serializable; +import java.util.Date; +import javax.annotation.Nullable; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.builder.EqualsBuilder; import org.apache.commons.lang.builder.HashCodeBuilder; import org.apache.commons.lang.builder.ToStringBuilder; import org.sonar.api.database.BaseIdentifiable; -import org.sonar.api.resources.Language; -import org.sonar.api.resources.Resource; - -import javax.annotation.Nullable; -import javax.persistence.*; - -import java.io.Serializable; -import java.util.Date; /** * Class to map resource with hibernate model diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssueComment.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssueComment.java index 1388477326f..205f13ebb3d 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssueComment.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssueComment.java @@ -37,7 +37,8 @@ public class DefaultIssueComment implements Serializable, IssueComment { private String issueKey; private String userLogin; - private Date createdAt, updatedAt; + private Date createdAt; + private Date updatedAt; private String key; private String markdownText; private boolean isNew; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java index b8b6eaefc2a..15298414088 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/FieldDiffs.java @@ -134,7 +134,8 @@ public class FieldDiffs implements Serializable { } public static class Diff<T extends Serializable> implements Serializable { - private T oldValue, newValue; + private T oldValue; + private T newValue; public Diff(@Nullable T oldValue, @Nullable T newValue) { this.oldValue = oldValue; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java index 7f9a1b1baf9..06e71528801 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoverageMeasuresBuilder.java @@ -40,7 +40,9 @@ public final class CoverageMeasuresBuilder { CoreMetrics.CONDITIONS_TO_COVER, CoreMetrics.UNCOVERED_CONDITIONS, CoreMetrics.CONDITIONS_BY_LINE, CoreMetrics.COVERED_CONDITIONS_BY_LINE); - private int totalCoveredLines = 0, totalConditions = 0, totalCoveredConditions = 0; + private int totalCoveredLines = 0; + private int totalConditions = 0; + private int totalCoveredConditions = 0; private SortedMap<Integer, Integer> hitsByLine = Maps.newTreeMap(); private SortedMap<Integer, Integer> conditionsByLine = Maps.newTreeMap(); private SortedMap<Integer, Integer> coveredConditionsByLine = Maps.newTreeMap(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeanAggregationFormula.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeanAggregationFormula.java index b679a6cc034..ec65d5a730f 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeanAggregationFormula.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/MeanAggregationFormula.java @@ -60,6 +60,6 @@ public class MeanAggregationFormula implements Formula { if (!hasValue && !forceZeroIfMissingData) { return null; } - return new Measure(context.getTargetMetric(), count==0 ? 0.0 : sum/count); + return new Measure(context.getTargetMetric(), (count==0) ? 0.0 : (sum/count)); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java index 1f3c4aa4240..c406861c236 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java @@ -56,7 +56,11 @@ public class Measure<G extends Serializable> implements Serializable { protected Metric.Level alertStatus; protected String alertText; protected Date date; - protected Double variation1, variation2, variation3, variation4, variation5; + protected Double variation1; + protected Double variation2; + protected Double variation3; + protected Double variation4; + protected Double variation5; protected String url; protected Characteristic characteristic; protected Requirement requirement; diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java index 8eaef70b9f5..5ca083bb929 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java @@ -274,8 +274,8 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a this.qualitative = qualitative; this.userManaged = userManaged; if (ValueType.PERCENT.equals(this.type)) { - this.bestValue = (direction == DIRECTION_BETTER ? 100.0 : 0.0); - this.worstValue = (direction == DIRECTION_BETTER ? 0.0 : 100.0); + this.bestValue = (direction == DIRECTION_BETTER) ? 100.0 : 0.0; + this.worstValue = (direction == DIRECTION_BETTER) ? 0.0 : 100.0; } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/WeightedMeanAggregationFormula.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/WeightedMeanAggregationFormula.java index c6daf0289ac..fc8900d8a94 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/WeightedMeanAggregationFormula.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/WeightedMeanAggregationFormula.java @@ -63,7 +63,7 @@ public class WeightedMeanAggregationFormula implements Formula { return null; } - double result = Double.doubleToRawLongBits(count)==0L ? 0.0 : sum/count; + double result = (Double.doubleToRawLongBits(count)==0L) ? 0.0 : (sum/count); return new Measure(context.getTargetMetric(), result); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java index 8cd7322115e..bca942ab196 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/StaxParser.java @@ -20,16 +20,20 @@ package org.sonar.api.utils; import com.ctc.wstx.stax.WstxInputFactory; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.StringUtils; -import org.codehaus.staxmate.SMInputFactory; -import org.codehaus.staxmate.in.SMHierarchicCursor; - -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; import java.net.URL; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLResolver; import javax.xml.stream.XMLStreamException; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.codehaus.staxmate.SMInputFactory; +import org.codehaus.staxmate.in.SMHierarchicCursor; /** * @since 1.10 diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/log/LogbackLogger.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/log/LogbackLogger.java index de1727a5be8..9a35b5bcf33 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/log/LogbackLogger.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/log/LogbackLogger.java @@ -19,9 +19,8 @@ */ package org.sonar.api.utils.log; -import ch.qos.logback.classic.*; +import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; - import javax.annotation.Nullable; /** |