diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-03 10:08:48 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-04-03 10:08:48 +0200 |
commit | 38e53c0572db4e267a704666cb0d1343992df5e1 (patch) | |
tree | 7b7bf7acb697d244dbf6ca03466b35c929662b24 /sonar-colorizer/src/main | |
parent | c881206bd9f2edfd6a5586ec735d003bd73d367d (diff) | |
download | sonarqube-38e53c0572db4e267a704666cb0d1343992df5e1.tar.gz sonarqube-38e53c0572db4e267a704666cb0d1343992df5e1.zip |
Fix some quality flaws
Diffstat (limited to 'sonar-colorizer/src/main')
4 files changed, 19 insertions, 15 deletions
diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java index f0cb0afabd6..d22f0c06a22 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/GroovyKeywords.java @@ -27,10 +27,9 @@ public final class GroovyKeywords { private static final Set<String> KEYWORDS = new HashSet<String>(); - private static final String[] GROOVY_KEYWORDS = new String[] { "as", "assert", "break", "case", "catch", "class", "continue", "def", - "default", "do" - , "else", "extends", "finally", "for", "if", "in", "implements", "import", "instanceof", "interface", "new", "package", - "property", "return", "switch", "throw", "throws", "try", "while" }; + private static final String[] GROOVY_KEYWORDS = new String[]{"as", "assert", "break", "case", "catch", "class", "continue", "def", + "default", "do", "else", "extends", "finally", "for", "if", "in", "implements", "import", "instanceof", "interface", "new", "package", + "property", "return", "switch", "throw", "throws", "try", "while"}; static { Collections.addAll(KEYWORDS, GROOVY_KEYWORDS); diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java index 97ddaf08c41..a9f00b5f1cd 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaKeywords.java @@ -27,11 +27,11 @@ public final class JavaKeywords { private static final Set<String> KEYWORDS = new HashSet<String>(); - private static final String[] JAVA_KEYWORDS = new String[] { "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", + private static final String[] JAVA_KEYWORDS = new String[]{"abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "default", - "do", "double", "else", "enum", "extends", "false", "final", "finally", "float", "for", + "do", "double", "else", "enum", "extends", "false", "final", "finally", "float", "for", "goto", "if", "implements", "import", "instanceof", - "int", "interface", "long", "native", "new", "null", "package", "private", + "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "void", "volatile", "while"}; diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaTokenizers.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaTokenizers.java index 4f9659f6aca..898eb969656 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaTokenizers.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/JavaTokenizers.java @@ -29,9 +29,13 @@ public final class JavaTokenizers { } public static List<Tokenizer> forHtml() { - return Collections.unmodifiableList(Arrays.asList(new JavaAnnotationTokenizer("<span class=\"a\">", "</span>"), new LiteralTokenizer( - "<span class=\"s\">", "</span>"), new CDocTokenizer("<span class=\"cd\">", "</span>"), new JavadocTokenizer("<span class=\"j\">", - "</span>"), new CppDocTokenizer("<span class=\"cppd\">", "</span>"), new JavaConstantTokenizer("<span class=\"c\">", "</span>"), + return Collections.unmodifiableList(Arrays.asList( + new JavaAnnotationTokenizer("<span class=\"a\">", "</span>"), + new LiteralTokenizer("<span class=\"s\">", "</span>"), + new CDocTokenizer("<span class=\"cd\">", "</span>"), + new JavadocTokenizer("<span class=\"j\">", "</span>"), + new CppDocTokenizer("<span class=\"cppd\">", "</span>"), + new JavaConstantTokenizer("<span class=\"c\">", "</span>"), new KeywordsTokenizer("<span class=\"k\">", "</span>", JavaKeywords.get()))); } } diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java index 116598731e8..9e15ea5474a 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/TokenizerDispatcher.java @@ -19,11 +19,11 @@ */ package org.sonar.colorizer; -import java.util.List; - import org.sonar.channel.Channel; import org.sonar.channel.CodeReader; +import java.util.List; + public class TokenizerDispatcher { private Channel[] tokenizers; @@ -32,8 +32,8 @@ public class TokenizerDispatcher { this.tokenizers = tokenizers; } - public TokenizerDispatcher(List<Channel<HtmlCodeBuilder>> tokenizers) { - this.tokenizers = tokenizers.toArray(new Channel[0]); // NOSONAR performance is not an issue here + public TokenizerDispatcher(List<Channel<HtmlCodeBuilder>> tokenizersArray) { + this.tokenizers = tokenizersArray.toArray(new Channel[tokenizersArray.size()]); } public final String colorize(String code) { @@ -44,7 +44,8 @@ public class TokenizerDispatcher { public final void colorize(CodeReader code, HtmlCodeBuilder colorizedCode) { cloneNotThreadSafeTokenizers(); - nextChar: while (code.peek() != -1) { + nextChar: + while (code.peek() != -1) { for (Channel<HtmlCodeBuilder> codeTokenizer : tokenizers) { if (codeTokenizer.consume(code, colorizedCode)) { continue nextChar; |