aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-06-30 16:08:07 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-06-30 16:08:20 +0200
commit0063b92f605464e8d684e5e4aabc41c23a04f513 (patch)
tree1784a758b2fb9807a6f0147020c4394df64cbaab /sonar-plugin-api
parent3f109b182cd3fa3d80f3a3b56e90fa4283e64e86 (diff)
downloadsonarqube-0063b92f605464e8d684e5e4aabc41c23a04f513.tar.gz
sonarqube-0063b92f605464e8d684e5e4aabc41c23a04f513.zip
Fix some quality flaws
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java18
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java12
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java27
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/profiles/XMLProfileParser.java20
6 files changed, 41 insertions, 44 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
index 88553184e82..769c0f521e6 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/CoreProperties.java
@@ -424,6 +424,7 @@ public interface CoreProperties {
* @since 4.0
* @deprecated in 5.1 no more used
*/
+ @Deprecated
String PREVIEW_READ_TIMEOUT_SEC = "sonar.preview.readTimeout";
/**
@@ -467,15 +468,14 @@ public interface CoreProperties {
* @since 4.0
*/
String WORKING_DIRECTORY = "sonar.working.directory";
-
+
String WORKING_DIRECTORY_DEFAULT_VALUE = ".sonar";
-
+
/**
* @since 5.2
*/
String GLOBAL_WORKING_DIRECTORY = "sonar.globalWorking.directory";
String GLOBAL_WORKING_DIRECTORY_DEFAULT_VALUE = ".";
-
/**
* @since 3.4
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
index 5cea4cad69d..df42847def6 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java
@@ -20,15 +20,6 @@
package org.sonar.api.batch.fs.internal;
import com.google.common.base.Preconditions;
-import org.sonar.api.batch.fs.InputFile;
-import org.sonar.api.batch.fs.TextPointer;
-import org.sonar.api.batch.fs.TextRange;
-import org.sonar.api.batch.fs.internal.FileMetadata.Metadata;
-import org.sonar.api.utils.PathUtils;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -37,6 +28,13 @@ import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.util.Arrays;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+import org.sonar.api.batch.fs.InputFile;
+import org.sonar.api.batch.fs.TextPointer;
+import org.sonar.api.batch.fs.TextRange;
+import org.sonar.api.batch.fs.internal.FileMetadata.Metadata;
+import org.sonar.api.utils.PathUtils;
/**
* @since 4.2
@@ -234,7 +232,7 @@ public class DefaultInputFile implements InputFile, org.sonar.api.resources.Inpu
return newRangeValidPointers(start, end);
}
- private TextRange newRangeValidPointers(TextPointer start, TextPointer end) {
+ private static TextRange newRangeValidPointers(TextPointer start, TextPointer end) {
Preconditions.checkArgument(start.compareTo(end) < 0, "Start pointer %s should be before end pointer %s", start, end);
return new DefaultTextRange(start, end);
}
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java
index 1712f50be88..1f1333a65bf 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java
@@ -20,6 +20,12 @@
package org.sonar.api.batch.sensor.highlighting.internal;
import com.google.common.base.Preconditions;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+import javax.annotation.Nullable;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.TextRange;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
@@ -28,10 +34,6 @@ import org.sonar.api.batch.sensor.highlighting.TypeOfText;
import org.sonar.api.batch.sensor.internal.DefaultStorable;
import org.sonar.api.batch.sensor.internal.SensorStorage;
-import javax.annotation.Nullable;
-
-import java.util.*;
-
public class DefaultHighlighting extends DefaultStorable implements NewHighlighting {
private DefaultInputFile inputFile;
@@ -56,7 +58,7 @@ public class DefaultHighlighting extends DefaultStorable implements NewHighlight
SyntaxHighlightingRule previous = it.next();
while (it.hasNext()) {
SyntaxHighlightingRule current = it.next();
- if (previous.range().end().compareTo(current.range().start()) > 0 && !(previous.range().end().compareTo(current.range().end()) >= 0)) {
+ if (previous.range().end().compareTo(current.range().start()) > 0 && (previous.range().end().compareTo(current.range().end()) < 0)) {
String errorMsg = String.format("Cannot register highlighting rule for characters at %s as it " +
"overlaps at least one existing rule", current.range());
throw new IllegalStateException(errorMsg);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
index 9b018f6bc2c..b264e35ce85 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/internal/SensorContextTester.java
@@ -20,6 +20,17 @@
package org.sonar.api.batch.sensor.internal;
import com.google.common.annotations.Beta;
+import java.io.File;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
import org.sonar.api.batch.AnalysisMode;
import org.sonar.api.batch.fs.InputDir;
import org.sonar.api.batch.fs.InputFile;
@@ -51,18 +62,6 @@ import org.sonar.api.batch.sensor.measure.internal.DefaultMeasure;
import org.sonar.api.config.Settings;
import org.sonar.api.measures.Metric;
-import javax.annotation.CheckForNull;
-import javax.annotation.Nullable;
-
-import java.io.File;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
/**
* Utility class to help testing {@link Sensor}.
*
@@ -321,13 +320,13 @@ public class SensorContextTester implements SensorContext {
public void store(DefaultCoverage defaultCoverage) {
String key = getKey(defaultCoverage.inputFile());
if (!coverageByComponent.containsKey(key)) {
- coverageByComponent.put(key, new HashMap<CoverageType, DefaultCoverage>());
+ coverageByComponent.put(key, new EnumMap<CoverageType, DefaultCoverage>(CoverageType.class));
}
coverageByComponent.get(key).put(defaultCoverage.type(), defaultCoverage);
}
@CheckForNull
- private String getKey(@Nullable InputPath inputPath) {
+ private static String getKey(@Nullable InputPath inputPath) {
if (inputPath == null) {
return null;
}
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 554e25db743..b66e440dba8 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
@@ -241,7 +241,7 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable, Serial
this.key = key;
}
- private void checkSize(String key) {
+ private static void checkSize(String key) {
if (key.length() > KEY_SIZE) {
throw new IllegalArgumentException("Resource key is too long, max is " + KEY_SIZE + " characters. Got : " + key);
}
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 c33d9e1d645..ea09d2bddfc 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
@@ -19,27 +19,25 @@
*/
package org.sonar.api.profiles;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.nio.charset.StandardCharsets;
+import java.util.HashMap;
+import java.util.Map;
+import javax.xml.stream.XMLInputFactory;
+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;
import org.codehaus.staxmate.in.SMInputCursor;
-import org.sonar.api.server.ServerSide;
import org.sonar.api.rules.ActiveRule;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
import org.sonar.api.rules.RulePriority;
+import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.ValidationMessages;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.nio.charset.StandardCharsets;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* @since 2.3
*/
@@ -160,7 +158,7 @@ public class XMLProfileParser {
}
}
- private String ruleToString(String repositoryKey, String key) {
+ private static String ruleToString(String repositoryKey, String key) {
return "[repository=" + repositoryKey + ", key=" + key + "]";
}