diff --git a/cxx-checks/pom.xml b/cxx-checks/pom.xml
index 7b76eb460d..4c1ad1f0eb 100644
--- a/cxx-checks/pom.xml
+++ b/cxx-checks/pom.xml
@@ -18,13 +18,11 @@
cxx-squid
${project.version}
-
org.sonarsource.sslr
sslr-testing-harness
test
-
junit
junit
diff --git a/cxx-checks/src/main/java/org/sonar/cxx/checks/ReservedNamesCheck.java b/cxx-checks/src/main/java/org/sonar/cxx/checks/ReservedNamesCheck.java
index 1c0b75537f..b08e4f22f9 100644
--- a/cxx-checks/src/main/java/org/sonar/cxx/checks/ReservedNamesCheck.java
+++ b/cxx-checks/src/main/java/org/sonar/cxx/checks/ReservedNamesCheck.java
@@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks;
-import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
@@ -61,7 +61,7 @@ public class ReservedNamesCheck extends SquidCheck implements CxxCharse
public void visitFile(AstNode astNode) {
List lines;
try {
- lines = Files.readLines(getContext().getFile(), charset);
+ lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/cxx-checks/src/main/java/org/sonar/cxx/checks/UseCorrectIncludeCheck.java b/cxx-checks/src/main/java/org/sonar/cxx/checks/UseCorrectIncludeCheck.java
index 6f0d8c2525..f3ffbe3481 100644
--- a/cxx-checks/src/main/java/org/sonar/cxx/checks/UseCorrectIncludeCheck.java
+++ b/cxx-checks/src/main/java/org/sonar/cxx/checks/UseCorrectIncludeCheck.java
@@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks;
-import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.List;
import java.util.regex.Pattern;
import org.sonar.check.Priority;
@@ -58,7 +58,7 @@ public class UseCorrectIncludeCheck extends SquidCheck implements CxxCh
public void visitFile(AstNode astNode) {
List lines;
try {
- lines = Files.readLines(getContext().getFile(), charset);
+ lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/cxx-checks/src/main/java/org/sonar/cxx/checks/file/TabCharacterCheck.java b/cxx-checks/src/main/java/org/sonar/cxx/checks/file/TabCharacterCheck.java
index 6c65a71322..3abb1f6824 100644
--- a/cxx-checks/src/main/java/org/sonar/cxx/checks/file/TabCharacterCheck.java
+++ b/cxx-checks/src/main/java/org/sonar/cxx/checks/file/TabCharacterCheck.java
@@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.file;
-import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.List;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
@@ -69,7 +69,7 @@ public void setCharset(Charset charset) {
public void visitFile(AstNode astNode) {
List lines;
try {
- lines = Files.readLines(getContext().getFile(), charset);
+ lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/cxx-checks/src/main/java/org/sonar/cxx/checks/metrics/TooLongLineCheck.java b/cxx-checks/src/main/java/org/sonar/cxx/checks/metrics/TooLongLineCheck.java
index 211f7f44dd..caff6a6272 100644
--- a/cxx-checks/src/main/java/org/sonar/cxx/checks/metrics/TooLongLineCheck.java
+++ b/cxx-checks/src/main/java/org/sonar/cxx/checks/metrics/TooLongLineCheck.java
@@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.metrics;
-import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.List;
import org.sonar.check.Priority;
import org.sonar.check.Rule;
@@ -80,7 +80,7 @@ public void setCharset(Charset charset) {
public void visitFile(AstNode astNode) {
List lines;
try {
- lines = Files.readLines(getContext().getFile(), charset);
+ lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/FileHeaderCheck.java b/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/FileHeaderCheck.java
index 57fffef2b6..98e9eb0fac 100644
--- a/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/FileHeaderCheck.java
+++ b/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/FileHeaderCheck.java
@@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.regex;
-import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
@@ -118,7 +118,7 @@ public void visitFile(AstNode astNode) {
if (isRegularExpression) {
String fileContent;
try {
- fileContent = Files.toString(getContext().getFile(), charset);
+ fileContent = new String(Files.readAllBytes(getContext().getFile().toPath()), charset);
} catch (IOException e) {
throw new AnalysisException(e);
}
@@ -126,7 +126,7 @@ public void visitFile(AstNode astNode) {
} else {
List lines;
try {
- lines = Files.readLines(getContext().getFile(), charset);
+ lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/FileRegularExpressionCheck.java b/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/FileRegularExpressionCheck.java
index f5767f5768..d88e1fa247 100644
--- a/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/FileRegularExpressionCheck.java
+++ b/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/FileRegularExpressionCheck.java
@@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.regex;
-import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.sonar.api.utils.PathUtils;
@@ -123,7 +123,7 @@ public void visitFile(AstNode fileNode) {
if (!compare(invertFilePattern, matchFile())) {
return;
}
- final String fileContent = Files.toString(getContext().getFile(), charset);
+ final String fileContent = new String(Files.readAllBytes(getContext().getFile().toPath()), charset);
Matcher matcher = pattern.matcher(fileContent);
if (compare(invertRegularExpression, matcher.find())) {
getContext().createFileViolation(this, message);
diff --git a/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/LineRegularExpressionCheck.java b/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/LineRegularExpressionCheck.java
index 6e7d0ae7b3..6dbcdeaf39 100644
--- a/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/LineRegularExpressionCheck.java
+++ b/cxx-checks/src/main/java/org/sonar/cxx/checks/regex/LineRegularExpressionCheck.java
@@ -19,12 +19,12 @@
*/
package org.sonar.cxx.checks.regex;
-import com.google.common.io.Files;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.Grammar;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -123,7 +123,7 @@ public void visitFile(AstNode fileNode) {
if (compare(invertFilePattern, matchFile())) {
List lines;
try {
- lines = Files.readLines(getContext().getFile(), charset);
+ lines = Files.readAllLines(getContext().getFile().toPath(), charset);
} catch (IOException e) {
throw new IllegalStateException(e);
}
diff --git a/cxx-lint/pom.xml b/cxx-lint/pom.xml
index af15a05658..5bc6323b6f 100644
--- a/cxx-lint/pom.xml
+++ b/cxx-lint/pom.xml
@@ -25,7 +25,7 @@
1.2.3
test
-
+
com.google.code.gson
gson
2.6.2
@@ -33,7 +33,7 @@
org.sonarsource.sonarqube
sonar-check-api
- 5.4
+ ${sonar.version}
jar
@@ -57,6 +57,11 @@
assertj-core
test
+
+ com.google.guava
+ guava
+ test
+
diff --git a/cxx-sensors/pom.xml b/cxx-sensors/pom.xml
index 563dec216f..aa8260df57 100644
--- a/cxx-sensors/pom.xml
+++ b/cxx-sensors/pom.xml
@@ -31,19 +31,16 @@
cxx-checks
${project.version}
-
org.sonarsource.sslr
sslr-testing-harness
test
-
org.sonarsource.sonarqube
sonar-testing-harness
test
-
org.apache.ant
ant
@@ -57,10 +54,6 @@
mockito-core
test
-
- com.google.guava
- guava
-
commons-io
commons-io
@@ -72,9 +65,8 @@
com.fasterxml.jackson.core
jackson-databind
- 2.9.7
+ 2.9.8
-
com.googlecode.plist
dd-plist
@@ -85,5 +77,10 @@
assertj-core
test
+
+ junit
+ junit
+ test
+
diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasures.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasures.java
index 8edfb4bfac..fe2aa67544 100644
--- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasures.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasures.java
@@ -19,10 +19,10 @@
*/
package org.sonar.cxx.sensors.coverage;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@@ -61,23 +61,23 @@ Collection getCoverageMeasures() {
}
Set getCoveredLines() {
- Set coveredLines = Sets.newHashSet();
+ Set coveredLines = new HashSet();
lineMeasures.forEach((key, value) -> {
if (value.getHits() != 0) {
coveredLines.add(value.getLine());
}
});
- return ImmutableSet.copyOf(coveredLines);
+ return Collections.unmodifiableSet(coveredLines);
}
Set getCoveredConditions() {
- Set coveredConditionLines = Sets.newHashSet();
+ Set coveredConditionLines = new HashSet();
lineMeasures.forEach((key, value) -> {
if (value.getCoveredConditions() != 0) {
coveredConditionLines.add(value.getLine());
}
});
- return ImmutableSet.copyOf(coveredConditionLines);
+ return Collections.unmodifiableSet(coveredConditionLines);
}
}
diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxChecks.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxChecks.java
index f7e914734d..d32aecac9a 100644
--- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxChecks.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxChecks.java
@@ -19,7 +19,6 @@
*/
package org.sonar.cxx.sensors.squid;
-import com.google.common.annotations.VisibleForTesting;
import com.sonar.sslr.api.Grammar;
import java.util.ArrayList;
import java.util.Arrays;
@@ -85,7 +84,6 @@ public RuleKey ruleKey(SquidAstVisitor check) {
return null;
}
- @VisibleForTesting
public Set>> getChecks() {
return new HashSet<>(checksByRepository);
}
diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxReportSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxReportSensor.java
index 00ff985fea..bd52be76cc 100644
--- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxReportSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxReportSensor.java
@@ -19,8 +19,6 @@
*/
package org.sonar.cxx.sensors.utils;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Iterables;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
@@ -139,7 +137,7 @@ public static List getReports(Configuration settings, final File moduleBas
* @return
*/
public static String[] splitProperty(String property) {
- return Iterables.toArray(Splitter.on(',').split(property), String.class);
+ return property.split(",");
}
/**
diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxFileLinesVisitor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxFileLinesVisitor.java
index d8b35f7992..7a15059b99 100644
--- a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxFileLinesVisitor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxFileLinesVisitor.java
@@ -19,7 +19,6 @@
*/
package org.sonar.cxx.sensors.visitors;
-import com.google.common.collect.Sets;
import com.sonar.sslr.api.AstAndTokenVisitor;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.GenericTokenType;
@@ -28,6 +27,7 @@
import com.sonar.sslr.api.TokenType;
import com.sonar.sslr.api.Trivia;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
@@ -235,9 +235,9 @@ public void leaveFile(AstNode astNode) {
if (LOG.isDebugEnabled()) {
LOG.debug("CxxFileLinesVisitor: '{}'", inputFile.uri().getPath());
LOG.debug(" lines: '{}'", inputFile.lines());
- LOG.debug(" executableLines: '{}'", Sets.newHashSet(executableLines));
- LOG.debug(" linesOfCode: '{}'", Sets.newHashSet(linesOfCode));
- LOG.debug(" linesOfComments: '{}'", Sets.newHashSet(linesOfComments));
+ LOG.debug(" executableLines: '{}'", new HashSet<>(executableLines));
+ LOG.debug(" linesOfCode: '{}'", new HashSet<>(linesOfCode));
+ LOG.debug(" linesOfComments: '{}'", new HashSet<>(linesOfComments));
}
linesOfCode = null;
diff --git a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/tests/dotnet/WildcardPatternFileProviderTest.java b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/tests/dotnet/WildcardPatternFileProviderTest.java
index 797fea80ba..3ed41784e1 100644
--- a/cxx-sensors/src/test/java/org/sonar/cxx/sensors/tests/dotnet/WildcardPatternFileProviderTest.java
+++ b/cxx-sensors/src/test/java/org/sonar/cxx/sensors/tests/dotnet/WildcardPatternFileProviderTest.java
@@ -23,7 +23,6 @@
// SonarQube .NET Tests Library
// Copyright (C) 2014-2017 SonarSource SA
// mailto:info AT sonarsource DOT com
-import com.google.common.base.Joiner;
import java.io.File;
import java.util.Set;
import static org.assertj.core.api.Assertions.assertThat;
@@ -41,7 +40,7 @@ public class WildcardPatternFileProviderTest {
public ExpectedException thrown = ExpectedException.none();
private static String path(String... elements) {
- return Joiner.on(File.separator).join(elements);
+ return String.join(File.separator, elements);
}
private static Set listFiles(String pattern) {
diff --git a/cxx-squid/pom.xml b/cxx-squid/pom.xml
index 8cf5459545..fa2b4da9e9 100644
--- a/cxx-squid/pom.xml
+++ b/cxx-squid/pom.xml
@@ -25,18 +25,15 @@
org.sonarsource.sslr-squid-bridge
sslr-squid-bridge
-
com.google.guava
guava
-
org.sonarsource.sslr
sslr-testing-harness
test
-
junit
junit
diff --git a/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java b/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java
index fa93abb6ed..00ba1508a3 100644
--- a/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java
+++ b/cxx-squid/src/main/java/org/sonar/cxx/preprocessor/CxxPreprocessor.java
@@ -19,9 +19,6 @@
*/
package org.sonar.cxx.preprocessor;
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.AstNodeType;
import static com.sonar.sslr.api.GenericTokenType.EOF;
@@ -40,6 +37,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
@@ -101,7 +99,7 @@ public class CxxPreprocessor extends Preprocessor {
private final List cFilesPatterns;
private final CxxConfiguration conf;
private CxxCompilationUnitSettings compilationUnitSettings;
- private final Multimap missingIncludeFiles = HashMultimap.create();
+ private final HashMap> missingIncludeFiles = new HashMap();
private boolean ctorInProgress = true;
private State currentFileState = new State(null);
@@ -165,7 +163,6 @@ public static void finalReport() {
}
}
- @VisibleForTesting
public static void resetReport() {
missingIncludeFilesCounter = 0;
}
@@ -441,7 +438,7 @@ private static String stripQuotes(String str) {
}
public Collection getMissingIncludeFiles(File file) {
- return missingIncludeFiles.get(file.getPath());
+ return missingIncludeFiles.getOrDefault(file.getPath(), new HashSet<>());
}
@Override
@@ -1078,7 +1075,8 @@ PreprocessorAction handleIncludeLine(AstNode ast, Token token, String filename,
}
if (conf.doCollectMissingIncludes()) {
final File currentFile = this.getFileUnderAnalysis();
- missingIncludeFiles.put(currentFile.getPath(), new Include(token.getLine(), token.getValue()));
+ missingIncludeFiles.computeIfAbsent(currentFile.getPath(), k -> new HashSet<>())
+ .add(new Include(token.getLine(), token.getValue()));
}
} else if (analysedFiles.add(includedFile.getAbsoluteFile())) {
if (LOG.isTraceEnabled()) {
diff --git a/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxParseErrorLoggerVisitor.java b/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxParseErrorLoggerVisitor.java
index c848599751..992fd884c4 100644
--- a/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxParseErrorLoggerVisitor.java
+++ b/cxx-squid/src/main/java/org/sonar/cxx/visitors/CxxParseErrorLoggerVisitor.java
@@ -19,7 +19,6 @@
*/
package org.sonar.cxx.visitors;
-import com.google.common.annotations.VisibleForTesting;
import com.sonar.sslr.api.AstNode;
import com.sonar.sslr.api.AstVisitor;
import com.sonar.sslr.api.GenericTokenType;
@@ -54,7 +53,6 @@ public static void finalReport() {
}
}
- @VisibleForTesting
public static void resetReport() {
errors = 0;
}
diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml
index 517cf3a567..dbbaffb6e3 100644
--- a/integration-tests/pom.xml
+++ b/integration-tests/pom.xml
@@ -103,13 +103,13 @@
- com.github.genthaler
+ com.github.genthaler
- beanshell-maven-plugin
+ beanshell-maven-plugin
- [1.2,)
+ [1.2,)
run
@@ -135,7 +135,7 @@
-
+
diff --git a/pom.xml b/pom.xml
index 8c237192ba..853eb544bc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -251,11 +251,6 @@
commons-lang
2.6
-
- com.google.guava
- guava
- 19.0
-
org.sonarsource.sonarqube
sonar-testing-harness
@@ -267,6 +262,11 @@
sslr-core
${sslr.version}
+
+ org.sonarsource.sslr
+ sslr-xpath
+ ${sslr.version}
+
org.sonarsource.sslr
sslr-testing-harness
@@ -287,6 +287,10 @@
org.codehaus.sonar.sslr
sslr-core
+
+ org.codehaus.sonar.sslr
+ sslr-xpath
+
org.codehaus.sonar
sonar-plugin-api
@@ -340,6 +344,11 @@
hamcrest-all
1.3
+
+ com.google.guava
+ guava
+ 19.0
+
diff --git a/sonar-c-plugin/pom.xml b/sonar-c-plugin/pom.xml
index 1e4995d518..9bddaf9096 100644
--- a/sonar-c-plugin/pom.xml
+++ b/sonar-c-plugin/pom.xml
@@ -8,7 +8,7 @@
1.2.2-SNAPSHOT
-
+
sonar-c-plugin
sonar-plugin
@@ -19,7 +19,7 @@
org.sonar.plugins.c.CPlugin
- C (Community)
+ C (Community)
target/${project.artifactId}-${project.version}.jar
@@ -51,15 +51,28 @@
${project.version}
- org.sonarsource.sonarqube
- sonar-testing-harness
- test
+ org.sonarsource.sslr
+ sslr-xpath
+
+
+ com.google.guava
+ guava
org.assertj
assertj-core
test
+
+ junit
+ junit
+ test
+
+
+ org.hamcrest
+ hamcrest-all
+ test
+
diff --git a/sonar-c-plugin/src/main/java/org/sonar/plugins/c/CPlugin.java b/sonar-c-plugin/src/main/java/org/sonar/plugins/c/CPlugin.java
index 1167b3bbea..9f28a414b7 100644
--- a/sonar-c-plugin/src/main/java/org/sonar/plugins/c/CPlugin.java
+++ b/sonar-c-plugin/src/main/java/org/sonar/plugins/c/CPlugin.java
@@ -93,7 +93,7 @@ public final class CPlugin implements Plugin {
private static List generalProperties() {
String subcateg = "(1) General";
- return new ArrayList<>(Arrays.asList(
+ return Collections.unmodifiableList(Arrays.asList(
PropertyDefinition.builder(SOURCE_FILE_SUFFIXES_KEY).multiValues(true)
.defaultValue(CLanguage.DEFAULT_SOURCE_SUFFIXES)
.name("Source files suffixes")
@@ -189,7 +189,7 @@ private static List generalProperties() {
private static List codeAnalysisProperties() {
String subcateg = "(2) Code analysis";
- return new ArrayList<>(Arrays.asList(PropertyDefinition.builder(LANG_PROP_PREFIX
+ return Collections.unmodifiableList(Arrays.asList(PropertyDefinition.builder(LANG_PROP_PREFIX
+ CxxCppCheckSensor.REPORT_PATH_KEY)
.name("Cppcheck report(s)")
.description("Path to a Cppcheck analysis XML report, "
@@ -354,7 +354,7 @@ private static List codeAnalysisProperties() {
private static List compilerWarningsProperties() {
String subcateg = "(4) Compiler warnings";
- return new ArrayList<>(Arrays.asList(
+ return Collections.unmodifiableList(Arrays.asList(
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCompilerVcSensor.REPORT_PATH_KEY)
.name("VC Compiler Report(s)")
.description("Path to compilers output (i.e. file(s) containg compiler warnings), relative to projects root."
@@ -430,7 +430,7 @@ private static List compilerWarningsProperties() {
private static List testingAndCoverageProperties() {
String subcateg = "(3) Testing & Coverage";
- return new ArrayList<>(Arrays.asList(
+ return Collections.unmodifiableList(Arrays.asList(
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCoverageSensor.REPORT_PATH_KEY)
.name("Unit test coverage report(s)")
.description("Path to a report containing unit test coverage data, relative to projects root."
@@ -465,7 +465,7 @@ private static List testingAndCoverageProperties() {
private static List duplicationsProperties() {
String subcateg = "(5) Duplications";
- return new ArrayList<>(Arrays.asList(
+ return Collections.unmodifiableList(Arrays.asList(
PropertyDefinition.builder(CPlugin.CPD_IGNORE_LITERALS_KEY)
.defaultValue(Boolean.FALSE.toString())
.name("Ignores literal value differences when evaluating a duplicate block")
diff --git a/sonar-cxx-plugin/pom.xml b/sonar-cxx-plugin/pom.xml
index 44fda14564..497b04a5ec 100644
--- a/sonar-cxx-plugin/pom.xml
+++ b/sonar-cxx-plugin/pom.xml
@@ -19,7 +19,7 @@
target/${project.artifactId}-${project.version}.jar
org.sonar.plugins.cxx.CxxPlugin
- C++ (Community)
+ C++ (Community)
@@ -49,13 +49,10 @@
cxx-sensors
${project.version}
-
- org.sonarsource.sonarqube
- sonar-testing-harness
- test
+ org.sonarsource.sslr
+ sslr-xpath
-
com.google.guava
guava
@@ -65,6 +62,16 @@
assertj-core
test
+
+ junit
+ junit
+ test
+
+
+ org.hamcrest
+ hamcrest-all
+ test
+
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/CxxPlugin.java b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/CxxPlugin.java
index 82c1ea649b..6e8ccf63e0 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/CxxPlugin.java
+++ b/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/CxxPlugin.java
@@ -19,7 +19,6 @@
*/
package org.sonar.plugins.cxx;
-import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -97,7 +96,7 @@ public final class CxxPlugin implements Plugin {
private static List generalProperties() {
String subcateg = "(1) General";
- return new ArrayList<>(Arrays.asList(
+ return Collections.unmodifiableList(Arrays.asList(
PropertyDefinition.builder(SOURCE_FILE_SUFFIXES_KEY)
.multiValues(true)
.defaultValue(CppLanguage.DEFAULT_SOURCE_SUFFIXES)
@@ -198,7 +197,7 @@ private static List generalProperties() {
private static List codeAnalysisProperties() {
String subcateg = "(2) Code analysis";
- return new ArrayList<>(Arrays.asList(PropertyDefinition.builder(LANG_PROP_PREFIX
+ return Collections.unmodifiableList(Arrays.asList(PropertyDefinition.builder(LANG_PROP_PREFIX
+ CxxCppCheckSensor.REPORT_PATH_KEY)
.name("Cppcheck report(s)")
.description("Path to a Cppcheck analysis XML report, relative to"
@@ -379,7 +378,7 @@ private static List codeAnalysisProperties() {
private static List compilerWarningsProperties() {
String subcateg = "(4) Compiler warnings";
- return new ArrayList<>(Arrays.asList(
+ return Collections.unmodifiableList(Arrays.asList(
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCompilerVcSensor.REPORT_PATH_KEY)
.name("VC Compiler Report(s)")
.description("Path to compilers output (i.e. file(s) containg compiler warnings), relative to projects root."
@@ -455,9 +454,7 @@ private static List compilerWarningsProperties() {
private static List testingAndCoverageProperties() {
String subcateg = "(3) Testing & Coverage";
- ImmutableList.Builder properties = ImmutableList.builder();
-
- properties.add(
+ return Collections.unmodifiableList(Arrays.asList(
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCoverageSensor.REPORT_PATH_KEY)
.name("Unit test coverage report(s)")
.description("List of paths to reports containing unit test coverage data, relative to projects root."
@@ -515,13 +512,12 @@ private static List testingAndCoverageProperties() {
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.index(6)
.build()
- );
- return properties.build();
+ ));
}
private static List duplicationsProperties() {
String subcateg = "(5) Duplications";
- return new ArrayList<>(Arrays.asList(
+ return Collections.unmodifiableList(Arrays.asList(
PropertyDefinition.builder(CxxPlugin.CPD_IGNORE_LITERALS_KEY)
.defaultValue(Boolean.FALSE.toString())
.name("Ignores literal value differences when evaluating a duplicate block")
diff --git a/sslr-cxx-toolkit/src/main/java/org/sonar/cxx/toolkit/CxxConfigurationModel.java b/sslr-cxx-toolkit/src/main/java/org/sonar/cxx/toolkit/CxxConfigurationModel.java
index 965a0b6969..7ded08c40a 100644
--- a/sslr-cxx-toolkit/src/main/java/org/sonar/cxx/toolkit/CxxConfigurationModel.java
+++ b/sslr-cxx-toolkit/src/main/java/org/sonar/cxx/toolkit/CxxConfigurationModel.java
@@ -19,7 +19,6 @@
*/
package org.sonar.cxx.toolkit;
-import com.google.common.annotations.VisibleForTesting;
import com.sonar.sslr.api.Grammar;
import com.sonar.sslr.impl.Parser;
import java.nio.charset.Charset;
@@ -58,32 +57,26 @@ public class CxxConfigurationModel extends AbstractConfigurationModel {
private final MapSettings settings = new MapSettings();
- @VisibleForTesting
ConfigurationProperty charsetProperty = new ConfigurationProperty("Charset", CHARSET_PROPERTY_KEY,
getPropertyOrDefaultValue(CHARSET_PROPERTY_KEY, "UTF-8"),
Validators.charsetValidator());
- @VisibleForTesting
ConfigurationProperty errorRecoveryEnabled = new ConfigurationProperty("Error Recovery", ERROR_RECOVERY_PROPERTY_KEY,
getPropertyOrDefaultValue(ERROR_RECOVERY_PROPERTY_KEY, "false"),
Validators.booleanValidator());
- @VisibleForTesting
ConfigurationProperty defines = new ConfigurationProperty("Defines", DEFINES_PROPERTY_KEY
+ " (use \\n\\ as separator)",
getPropertyOrDefaultValue(DEFINES_PROPERTY_KEY, ""));
- @VisibleForTesting
ConfigurationProperty includeDirectories = new ConfigurationProperty("Include Directories",
INCLUDE_DIRECTORIES_PROPERTY_KEY + " (use , as separator)",
getPropertyOrDefaultValue(INCLUDE_DIRECTORIES_PROPERTY_KEY, ""));
- @VisibleForTesting
ConfigurationProperty forceIncludes = new ConfigurationProperty("Force Includes", FORCE_INCLUDES_PROPERTY_KEY
+ " (use , as separator)",
getPropertyOrDefaultValue(FORCE_INCLUDES_PROPERTY_KEY, ""));
- @VisibleForTesting
static String getPropertyOrDefaultValue(String propertyKey, String defaultValue) {
String propertyValue = System.getProperty(propertyKey);
@@ -144,7 +137,6 @@ public List doGetTokenizers() {
);
}
- @VisibleForTesting
CxxConfiguration getConfiguration(CxxLanguage language) {
CxxConfiguration config = new CxxConfiguration(getCharset());
config.setErrorRecoveryEnabled("true".equals(errorRecoveryEnabled.getValue()));