aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications/src
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-11-10 17:51:08 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-11-10 17:51:08 +0100
commitf613b749354c6268d902f58f71b32879399c7548 (patch)
treea9a6ebeac1959ce941dbcd0bf307ef7a06033981 /sonar-duplications/src
parentcb010a0100bceb937d43fb4ff44bba281afa27f9 (diff)
downloadsonarqube-f613b749354c6268d902f58f71b32879399c7548.tar.gz
sonarqube-f613b749354c6268d902f58f71b32879399c7548.zip
fix quality flaws
Diffstat (limited to 'sonar-duplications/src')
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java6
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChannel.java18
-rw-r--r--sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChunker.java12
3 files changed, 18 insertions, 18 deletions
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java b/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java
index ed78b2d9fb7..02c09597396 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/statement/Statement.java
@@ -19,11 +19,11 @@
*/
package org.sonar.duplications.statement;
+import java.util.List;
+import javax.annotation.Nullable;
import org.sonar.duplications.CodeFragment;
import org.sonar.duplications.token.Token;
-import java.util.List;
-
public class Statement implements CodeFragment {
private final int startLine;
@@ -41,7 +41,7 @@ public class Statement implements CodeFragment {
this.value = value;
}
- public Statement(List<Token> tokens) {
+ public Statement(@Nullable List<Token> tokens) {
if (tokens == null || tokens.isEmpty()) {
throw new IllegalArgumentException("A statement can't be initialized with an empty list of tokens");
}
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChannel.java b/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChannel.java
index af89c8dc483..67646bcc323 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChannel.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChannel.java
@@ -21,7 +21,7 @@ package org.sonar.duplications.statement;
import java.util.ArrayList;
import java.util.List;
-
+import javax.annotation.Nullable;
import org.sonar.duplications.statement.matcher.TokenMatcher;
import org.sonar.duplications.token.Token;
import org.sonar.duplications.token.TokenQueue;
@@ -31,6 +31,14 @@ public final class StatementChannel {
private final TokenMatcher[] tokenMatchers;
private final boolean blackHole;
+ private StatementChannel(boolean blackHole, @Nullable TokenMatcher... tokenMatchers) {
+ if (tokenMatchers == null || tokenMatchers.length == 0) {
+ throw new IllegalArgumentException();
+ }
+ this.blackHole = blackHole;
+ this.tokenMatchers = tokenMatchers;
+ }
+
public static StatementChannel create(TokenMatcher... tokenMatchers) {
return new StatementChannel(false, tokenMatchers);
}
@@ -39,14 +47,6 @@ public final class StatementChannel {
return new StatementChannel(true, tokenMatchers);
}
- private StatementChannel(boolean blackHole, TokenMatcher... tokenMatchers) {
- if (tokenMatchers == null || tokenMatchers.length == 0) {
- throw new IllegalArgumentException();
- }
- this.blackHole = blackHole;
- this.tokenMatchers = tokenMatchers;
- }
-
public boolean consume(TokenQueue tokenQueue, List<Statement> output) {
List<Token> matchedTokenList = new ArrayList<>();
for (TokenMatcher tokenMatcher : tokenMatchers) {
diff --git a/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChunker.java b/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChunker.java
index f0ac6f28777..00757ec3c9b 100644
--- a/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChunker.java
+++ b/sonar-duplications/src/main/java/org/sonar/duplications/statement/StatementChunker.java
@@ -21,7 +21,7 @@ package org.sonar.duplications.statement;
import java.util.ArrayList;
import java.util.List;
-
+import javax.annotation.Nullable;
import org.sonar.duplications.DuplicationsException;
import org.sonar.duplications.statement.matcher.TokenMatcher;
import org.sonar.duplications.token.TokenQueue;
@@ -30,15 +30,15 @@ public final class StatementChunker {
private final StatementChannelDisptacher channelDispatcher;
- public static Builder builder() {
- return new Builder();
- }
-
private StatementChunker(Builder builder) {
this.channelDispatcher = builder.getChannelDispatcher();
}
- public List<Statement> chunk(TokenQueue tokenQueue) {
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ public List<Statement> chunk(@Nullable TokenQueue tokenQueue) {
if (tokenQueue == null) {
throw new IllegalArgumentException();
}