summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeny Mandrikov <mandrikov@gmail.com>2011-11-03 12:32:03 +0400
committerEvgeny Mandrikov <mandrikov@gmail.com>2011-11-03 13:10:43 +0400
commitcab01ac39897c39b0b669c04823da607c376c93e (patch)
tree0207f03193f8f3dc8fa9f0ef9cc44d227ebee3e2
parentd234f0fbdb75112af3f39a9b4fb85ac9fe0552ed (diff)
downloadsonarqube-cab01ac39897c39b0b669c04823da607c376c93e.tar.gz
sonarqube-cab01ac39897c39b0b669c04823da607c376c93e.zip
Fix violations
-rw-r--r--plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/ComplexityVisitor.java4
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/JavaAnnotationTokenizer.java5
-rw-r--r--sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java6
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java2
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/command/CommandExecutor.java32
5 files changed, 22 insertions, 27 deletions
diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/ComplexityVisitor.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/ComplexityVisitor.java
index 07b9e0b9c18..60aef739ef9 100644
--- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/ComplexityVisitor.java
+++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/java/ast/visitor/ComplexityVisitor.java
@@ -32,7 +32,7 @@ public class ComplexityVisitor extends JavaAstVisitor {
@Override
public List<Integer> getWantedTokens() {
- return wantedTokens;
+ return WANTED_TOKENS;
}
@Override
@@ -41,6 +41,6 @@ public class ComplexityVisitor extends JavaAstVisitor {
res.setMeasure(Metric.COMPLEXITY, res.getInt(Metric.COMPLEXITY) + res.getInt(Metric.BRANCHES) + 1);
}
- private static final List<Integer> wantedTokens = Arrays.asList(TokenTypes.CTOR_DEF, TokenTypes.METHOD_DEF, TokenTypes.INSTANCE_INIT,
+ private static final List<Integer> WANTED_TOKENS = Arrays.asList(TokenTypes.CTOR_DEF, TokenTypes.METHOD_DEF, TokenTypes.INSTANCE_INIT,
TokenTypes.STATIC_INIT);
}
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaAnnotationTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaAnnotationTokenizer.java
index 554e0613fac..1a5489e75f5 100644
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaAnnotationTokenizer.java
+++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaAnnotationTokenizer.java
@@ -32,8 +32,7 @@ public class JavaAnnotationTokenizer extends Tokenizer {
this.tagAfter = tagAfter;
}
- private static final EndMatcher endTokenMatcher = new EndMatcher() {
-
+ private static final EndMatcher END_TOKEN_MATCHER = new EndMatcher() {
public boolean match(int endFlag) {
return !Character.isJavaIdentifierPart(endFlag);
}
@@ -43,7 +42,7 @@ public class JavaAnnotationTokenizer extends Tokenizer {
public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
if (code.peek() == '@') {
codeBuilder.appendWithoutTransforming(tagBefore);
- code.popTo(endTokenMatcher, codeBuilder);
+ code.popTo(END_TOKEN_MATCHER, codeBuilder);
codeBuilder.appendWithoutTransforming(tagAfter);
return true;
} else {
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java
index 3152b41161f..9bf9225461c 100644
--- a/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java
+++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/KeywordsTokenizer.java
@@ -37,12 +37,12 @@ public class KeywordsTokenizer extends NotThreadSafeTokenizer {
private boolean caseInsensitive = false;
private Matcher matcher;
private final StringBuilder tmpBuilder = new StringBuilder();
- private final static String defaultRegex = "[a-zA-Z_][a-zA-Z0-9_]*+";
+ private final static String DEFAULT_REGEX = "[a-zA-Z_][a-zA-Z0-9_]*+";
private Set<String> keywords = new HashSet<String>();
public KeywordsTokenizer(String tagBefore, String tagAfter, Set<String> keywords) {
- this(tagBefore, tagAfter, keywords, defaultRegex);
+ this(tagBefore, tagAfter, keywords, DEFAULT_REGEX);
}
public KeywordsTokenizer(String tagBefore, String tagAfter, Set<String> keywords, String regex) {
@@ -56,7 +56,7 @@ public class KeywordsTokenizer extends NotThreadSafeTokenizer {
this.tagBefore = tagBefore;
this.tagAfter = tagAfter;
Collections.addAll(this.keywords, keywords);
- this.matcher = Pattern.compile(defaultRegex).matcher("");
+ this.matcher = Pattern.compile(DEFAULT_REGEX).matcher("");
}
public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) {
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java
index e6bb142a5c2..268111244d4 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/WildcardPattern.java
@@ -53,7 +53,7 @@ import org.apache.commons.lang.StringUtils;
* </p>
* <p>
* Another implementation, which is also based on Java Regular Expressions, can be found in
- * <a href="https://github.com/JetBrains/intellij-community/blob/59fa7d3aa565b01ecf0fb067a4336af2c174bf5b/platform/util/src/com/intellij/openapi/util/io/FileUtil.java#L865">FileUtil</a>
+ * <a href="https://github.com/JetBrains/intellij-community/blob/idea/107.743/platform/util/src/com/intellij/openapi/util/io/FileUtil.java#L847">FileUtil</a>
* from IntelliJ OpenAPI.
* </p>
*
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/command/CommandExecutor.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/command/CommandExecutor.java
index 1980f870c3d..26c719cddd9 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/command/CommandExecutor.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/command/CommandExecutor.java
@@ -86,17 +86,9 @@ public final class CommandExecutor {
throw new CommandException(command, e);
} finally {
- if (outputGobbler != null) {
- waitUntilFinish(outputGobbler);
- }
-
- if (errorGobbler != null) {
- waitUntilFinish(errorGobbler);
- }
-
- if (process != null) {
- closeStreams(process);
- }
+ waitUntilFinish(outputGobbler);
+ waitUntilFinish(errorGobbler);
+ closeStreams(process);
if (executorService != null) {
executorService.shutdown();
@@ -105,16 +97,20 @@ public final class CommandExecutor {
}
private void closeStreams(Process process) {
- IOUtils.closeQuietly(process.getInputStream());
- IOUtils.closeQuietly(process.getOutputStream());
- IOUtils.closeQuietly(process.getErrorStream());
+ if (process != null) {
+ IOUtils.closeQuietly(process.getInputStream());
+ IOUtils.closeQuietly(process.getOutputStream());
+ IOUtils.closeQuietly(process.getErrorStream());
+ }
}
private void waitUntilFinish(StreamGobbler thread) {
- try {
- thread.join();
- } catch (InterruptedException e) {
- // ignore
+ if (thread != null) {
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ // ignore
+ }
}
}