aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2015-06-04 12:21:37 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2015-06-04 12:21:46 +0200
commit93e2db9c467f56954a1a2f33a45ab57a3cf24d75 (patch)
tree231c92b60cdd7b0462b0ce8a5517ea45235a530b /sonar-plugin-api
parentc85a386fbdd2994e6a32cb2ad24144fedd027db6 (diff)
downloadsonarqube-93e2db9c467f56954a1a2f33a45ab57a3cf24d75.tar.gz
sonarqube-93e2db9c467f56954a1a2f33a45ab57a3cf24d75.zip
Fix quality flaws
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/charts/AbstractChart.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/charts/ChartParameters.java3
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/component/mock/MockSourceFile.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/Measure.java8
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/user/UserQuery.java2
16 files changed, 29 insertions, 28 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
index e4bc8948523..0dc747a25bf 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/rule/Checks.java
@@ -161,7 +161,7 @@ public class Checks<C> {
}
}
- private RuntimeException failToInstantiateCheck(ActiveRule activeRule, Object checkClassOrInstance, Exception e) {
+ private static RuntimeException failToInstantiateCheck(ActiveRule activeRule, Object checkClassOrInstance, Exception e) {
throw new IllegalStateException(String.format("Fail to instantiate class %s for rule %s", checkClassOrInstance, activeRule.ruleKey()), e);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/charts/AbstractChart.java b/sonar-plugin-api/src/main/java/org/sonar/api/charts/AbstractChart.java
index acbeb318b96..d0e646c0e0d 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/charts/AbstractChart.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/charts/AbstractChart.java
@@ -63,7 +63,7 @@ public abstract class AbstractChart implements Chart {
return chart.createBufferedImage(params.getWidth(), params.getHeight());
}
- private void improveChart(JFreeChart jfrechart, ChartParameters params) {
+ private static void improveChart(JFreeChart jfrechart, ChartParameters params) {
Color background = Color.decode("#" + params.getValue(ChartParameters.PARAM_BACKGROUND_COLOR, "FFFFFF", false));
jfrechart.setBackgroundPaint(background);
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 e898e621f21..15eb2f256c2 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
@@ -19,6 +19,7 @@
*/
package org.sonar.api.charts;
+import javax.annotation.Nullable;
import org.apache.commons.lang.CharEncoding;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.text.StrTokenizer;
@@ -173,7 +174,7 @@ public class ChartParameters {
return Locale.ENGLISH;
}
- private String decode(String val) {
+ private static String decode(@Nullable String val) {
if (val != null) {
try {
val = URLDecoder.decode(val, CharEncoding.UTF_8);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/component/mock/MockSourceFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/component/mock/MockSourceFile.java
index 7388ff7b2aa..f2f6efd3652 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/component/mock/MockSourceFile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/component/mock/MockSourceFile.java
@@ -101,7 +101,7 @@ public class MockSourceFile implements SourceFile {
}
MockSourceFile that = (MockSourceFile) o;
- return !(key != null ? !key.equals(that.key) : that.key != null);
+ return !(key != null ? !key.equals(that.key) : (that.key != null));
}
@Override
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java
index db09f62cef2..a586619a652 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/issue/internal/DefaultIssue.java
@@ -557,7 +557,7 @@ public class DefaultIssue implements Issue {
return false;
}
DefaultIssue that = (DefaultIssue) o;
- return !(key != null ? !key.equals(that.key) : that.key != null);
+ return !(key != null ? !key.equals(that.key) : (that.key != null));
}
@Override
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 2acf8a09af3..3d535d401b4 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
@@ -335,7 +335,7 @@ public class Measure<G extends Serializable> implements Serializable {
return this;
}
- private double scaleValue(double value, int scale) {
+ private static double scaleValue(double value, int scale) {
BigDecimal bd = BigDecimal.valueOf(value);
return bd.setScale(scale, RoundingMode.HALF_UP).doubleValue();
}
@@ -730,13 +730,13 @@ public class Measure<G extends Serializable> implements Serializable {
}
Measure measure = (Measure) o;
- if (metricKey != null ? !metricKey.equals(measure.metricKey) : measure.metricKey != null) {
+ if (metricKey != null ? !metricKey.equals(measure.metricKey) : (measure.metricKey != null)) {
return false;
}
- if (characteristic != null ? !characteristic.equals(measure.characteristic) : measure.characteristic != null) {
+ if (characteristic != null ? !characteristic.equals(measure.characteristic) : (measure.characteristic != null)) {
return false;
}
- return !(personId != null ? !personId.equals(measure.personId) : measure.personId != null);
+ return !(personId != null ? !personId.equals(measure.personId) : (measure.personId != null));
}
@Override
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java
index 2b4471ef5b7..26d82c1fdcf 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/RangeDistributionBuilder.java
@@ -166,7 +166,7 @@ public class RangeDistributionBuilder implements MeasureBuilder {
return this;
}
- private boolean areSameLimits(Number[] bottomLimits, Set<Double> limits) {
+ private static boolean areSameLimits(Number[] bottomLimits, Set<Double> limits) {
if (limits.size() == bottomLimits.length) {
for (Number l : bottomLimits) {
if (!limits.contains(l.doubleValue())) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java
index bf57092a947..d0eeb1ac824 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/ProfileImporter.java
@@ -64,7 +64,7 @@ public abstract class ProfileImporter {
}
protected final ProfileImporter setSupportedLanguages(String... languages) {
- supportedLanguages = (languages != null ? languages : new String[0]);
+ supportedLanguages = (languages != null) ? languages : new String[0];
return this;
}
@@ -84,12 +84,12 @@ public abstract class ProfileImporter {
return false;
}
ProfileImporter that = (ProfileImporter) o;
- return !(importerKey != null ? !importerKey.equals(that.importerKey) : that.importerKey != null);
+ return !((importerKey != null) ? !importerKey.equals(that.importerKey) : (that.importerKey != null));
}
@Override
public final int hashCode() {
- return importerKey != null ? importerKey.hashCode() : 0;
+ return (importerKey != null) ? importerKey.hashCode() : 0;
}
@Override
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java
index 9f6e5991988..78d6ea7b34f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java
@@ -96,7 +96,7 @@ public class XMLProfileParser {
return profile;
}
- private void checkProfile(RulesProfile profile, ValidationMessages messages) {
+ private static void checkProfile(RulesProfile profile, ValidationMessages messages) {
if (StringUtils.isBlank(profile.getName())) {
messages.addErrorText("The mandatory node <name> is missing.");
}
@@ -105,7 +105,7 @@ public class XMLProfileParser {
}
}
- private SMInputFactory initStax() {
+ private static SMInputFactory initStax() {
XMLInputFactory xmlFactory = XMLInputFactory.newInstance();
xmlFactory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.TRUE);
xmlFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.FALSE);
@@ -163,7 +163,7 @@ public class XMLProfileParser {
return "[repository=" + repositoryKey + ", key=" + key + "]";
}
- private void processParameters(SMInputCursor propsCursor, Map<String, String> parameters) throws XMLStreamException {
+ private static void processParameters(SMInputCursor propsCursor, Map<String, String> parameters) throws XMLStreamException {
while (propsCursor.getNext() != null) {
SMInputCursor propCursor = propsCursor.childElementCursor();
String key = null;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java
index 78a4f12807e..b7204361166 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileSerializer.java
@@ -46,7 +46,7 @@ public class XMLProfileSerializer {
}
}
- private void appendHeader(RulesProfile profile, Writer writer) throws IOException {
+ private static void appendHeader(RulesProfile profile, Writer writer) throws IOException {
writer.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<!-- Generated by SonarQube -->"
+ "<profile><name>");
@@ -56,7 +56,7 @@ public class XMLProfileSerializer {
writer.append("</language>");
}
- private void appendRules(RulesProfile profile, Writer writer) throws IOException {
+ private static void appendRules(RulesProfile profile, Writer writer) throws IOException {
if (!profile.getActiveRules().isEmpty()) {
writer.append("<rules>");
for (ActiveRule activeRule : profile.getActiveRules()) {
@@ -66,7 +66,7 @@ public class XMLProfileSerializer {
}
}
- private void appendRule(ActiveRule activeRule, Writer writer) throws IOException {
+ private static void appendRule(ActiveRule activeRule, Writer writer) throws IOException {
writer.append("<rule><repositoryKey>");
writer.append(activeRule.getRepositoryKey());
writer.append("</repositoryKey><key>");
@@ -81,7 +81,7 @@ public class XMLProfileSerializer {
writer.append("</rule>");
}
- private void appendRuleParameters(ActiveRule activeRule, Writer writer) throws IOException {
+ private static void appendRuleParameters(ActiveRule activeRule, Writer writer) throws IOException {
if (activeRule.getActiveRuleParams() != null && !activeRule.getActiveRuleParams().isEmpty()) {
writer.append("<parameters>");
for (ActiveRuleParam activeRuleParam : activeRule.getActiveRuleParams()) {
@@ -91,7 +91,7 @@ public class XMLProfileSerializer {
}
}
- private void appendRuleParameter(Writer writer, ActiveRuleParam activeRuleParam) throws IOException {
+ private static void appendRuleParameter(Writer writer, ActiveRuleParam activeRuleParam) throws IOException {
if (StringUtils.isNotBlank(activeRuleParam.getValue())) {
writer.append("<parameter><key>");
StringEscapeUtils.escapeXml(writer, activeRuleParam.getKey());
@@ -102,7 +102,7 @@ public class XMLProfileSerializer {
}
}
- private void appendFooter(Writer writer) throws IOException {
+ private static void appendFooter(Writer writer) throws IOException {
writer.append("</profile>");
}
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java
index 86f207d9c93..d6fe54b8be3 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/rules/ActiveRule.java
@@ -268,7 +268,7 @@ public class ActiveRule implements Cloneable {
if (!rule.equals(that.rule)) {
return false;
}
- return !(rulesProfile != null ? !rulesProfile.equals(that.rulesProfile) : that.rulesProfile != null);
+ return !((rulesProfile != null) ? !rulesProfile.equals(that.rulesProfile) : (that.rulesProfile != null));
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java
index 3adf21d92b5..c905e8f9bb5 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/scan/filesystem/PathResolver.java
@@ -89,7 +89,7 @@ public class PathResolver {
}
@CheckForNull
- private File parentDir(Collection<File> dirs, File cursor) {
+ private static File parentDir(Collection<File> dirs, File cursor) {
for (File dir : dirs) {
if (PathUtils.canonicalPath(dir).equals(PathUtils.canonicalPath(cursor))) {
return dir;
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
index d9ac5cb7813..a5bd987880c 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/debt/internal/DefaultDebtRemediationFunction.java
@@ -45,7 +45,7 @@ public class DefaultDebtRemediationFunction implements DebtRemediationFunction {
}
@CheckForNull
- private String sanitizeValue(String label, @Nullable String s) {
+ private static String sanitizeValue(String label, @Nullable String s) {
if (StringUtils.isNotBlank(s)) {
try {
Duration duration = Duration.decode(s, HOURS_IN_DAY);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java
index af6d5cb7a2e..4e193931bf8 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/server/ws/internal/ValidatingRequest.java
@@ -125,7 +125,7 @@ public abstract class ValidatingRequest extends Request {
@CheckForNull
protected abstract InputStream readInputStreamParam(String key);
- private void validate(String value, WebService.Param definition) {
+ private static void validate(String value, WebService.Param definition) {
Set<String> possibleValues = definition.possibleValues();
if (possibleValues != null && !possibleValues.contains(value)) {
throw new IllegalArgumentException(String.format(
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java
index 06d2c2b53bb..846a53efe3f 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/technicaldebt/server/internal/DefaultCharacteristic.java
@@ -331,7 +331,7 @@ public class DefaultCharacteristic implements Characteristic {
if ((key != null) ? !key.equals(that.key) : (that.key != null)) {
return false;
}
- return !(ruleKey != null ? !ruleKey.equals(that.ruleKey) : that.ruleKey != null);
+ return !((ruleKey != null) ? !ruleKey.equals(that.ruleKey) : (that.ruleKey != null));
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/user/UserQuery.java b/sonar-plugin-api/src/main/java/org/sonar/api/user/UserQuery.java
index 2cd3e989808..190a5b83e26 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/user/UserQuery.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/user/UserQuery.java
@@ -48,7 +48,7 @@ public class UserQuery {
this.searchTextSql = searchTextToSql(searchText);
}
- private String searchTextToSql(@Nullable String s) {
+ private static String searchTextToSql(@Nullable String s) {
String sql = null;
if (s != null) {
sql = StringUtils.replace(s, "%", "/%");