diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/BooleanEqualityComparisonCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/BooleanEqualityComparisonCheckTest.java
index c423bd5dbe..16f99c63ee 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/BooleanEqualityComparisonCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/BooleanEqualityComparisonCheckTest.java
@@ -36,7 +36,7 @@ public class BooleanEqualityComparisonCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/BooleanEqualityComparisonCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new BooleanEqualityComparisonCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new BooleanEqualityComparisonCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(12).withMessage("Remove the unnecessary boolean comparison to simplify this expression.")
.next().atLine(13)
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/ClassComplexityCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/ClassComplexityCheckTest.java
index c85f375cc0..99b4394706 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/ClassComplexityCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/ClassComplexityCheckTest.java
@@ -35,7 +35,7 @@ public void test() throws UnsupportedEncodingException, IOException {
check.setMaximumClassComplexityThreshold(5);
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/ClassComplexity.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(9).withMessage("Class has a complexity of 10 which is greater than 5 authorized.")
.noMore();
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/CollapsibleIfCandidateCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/CollapsibleIfCandidateCheckTest.java
index 2b82e511b5..453caee8cb 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/CollapsibleIfCandidateCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/CollapsibleIfCandidateCheckTest.java
@@ -36,7 +36,7 @@ public class CollapsibleIfCandidateCheckTest {
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/CollapsibleIfCandidateCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new CollapsibleIfCandidateCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new CollapsibleIfCandidateCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(16).withMessage("Merge this if statement with the enclosing one.")
.next().atLine(49)
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/CommentRegularExpressionCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/CommentRegularExpressionCheckTest.java
index 2df06f9c9f..925e6d343b 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/CommentRegularExpressionCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/CommentRegularExpressionCheckTest.java
@@ -38,7 +38,7 @@ public void test() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/commentRegularExpression.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(3).withMessage("Avoid TODO")
.next().atLine(5)
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/CommentedCodeCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/CommentedCodeCheckTest.java
index 7d26309b1f..be7d8fcf55 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/CommentedCodeCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/CommentedCodeCheckTest.java
@@ -36,7 +36,7 @@ public class CommentedCodeCheckTest {
@Test
public void test() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/commentedCode.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new CommentedCodeCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new CommentedCodeCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(10).withMessage("Remove this commented out code.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/CxxFileTesterHelper.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/CxxFileTesterHelper.java
index 96e55a411f..d844158116 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/CxxFileTesterHelper.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/CxxFileTesterHelper.java
@@ -23,8 +23,11 @@
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
+import org.mockito.Mockito;
+import static org.mockito.Mockito.when;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
import org.sonar.api.batch.sensor.internal.SensorContextTester;
+import org.sonar.cxx.CxxLanguage;
/**
*
@@ -53,5 +56,16 @@ public static CxxFileTester CreateCxxFileTester(String fileName, String basePath
return tester;
}
-
+
+ public static CxxLanguage mockCxxLanguage() {
+ CxxLanguage language = Mockito.mock(CxxLanguage.class);
+ when(language.getKey()).thenReturn("c++");
+ when(language.getName()).thenReturn("c++");
+ when(language.getPropertiesKey()).thenReturn("cxx");
+ when(language.IsRecoveryEnabled()).thenReturn(true);
+ when(language.getFileSuffixes())
+ .thenReturn(new String [] { ".cpp", ".hpp", ".h", ".cxx", ".c", ".cc", ".hxx", ".hh" });
+
+ return language;
+ }
}
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/FileComplexityCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/FileComplexityCheckTest.java
index 8d86636ea7..7995225bac 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/FileComplexityCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/FileComplexityCheckTest.java
@@ -40,7 +40,7 @@ public void check() throws UnsupportedEncodingException, IOException {
check.setMax(1);
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/functions.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().noMore();
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/FileEncodingCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/FileEncodingCheckTest.java
index b27d21a41c..0dc274e5a1 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/FileEncodingCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/FileEncodingCheckTest.java
@@ -36,9 +36,9 @@ public class FileEncodingCheckTest {
@Test
public void testAsciiFileAsciiEncoding() throws UnsupportedEncodingException, IOException {
Charset charset = Charset.forName("US-ASCII");
- CxxConfiguration cxxConfig = new CxxConfiguration(charset);
+ CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TabCharacter.cc", ".", "US-ASCII");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, cxxConfig, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
@@ -47,9 +47,9 @@ public void testAsciiFileAsciiEncoding() throws UnsupportedEncodingException, IO
@Test
public void testAsciiFileUtf8Encoding() throws UnsupportedEncodingException, IOException {
Charset charset = Charset.forName("UTF-8");
- CxxConfiguration cxxConfig = new CxxConfiguration(charset);
+ CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TabCharacter.cc", ".", "UTF-8");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, cxxConfig, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
@@ -58,9 +58,9 @@ public void testAsciiFileUtf8Encoding() throws UnsupportedEncodingException, IOE
@Test
public void testUnicodeFileUtf16Encoding() throws UnsupportedEncodingException, IOException {
Charset charset = Charset.forName("UTF-16");
- CxxConfiguration cxxConfig = new CxxConfiguration(charset);
+ CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/Unicode.cc", ".", "UTF-16");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, cxxConfig, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
}
@@ -68,9 +68,9 @@ public void testUnicodeFileUtf16Encoding() throws UnsupportedEncodingException,
@Test
public void testUnicodeFileAsciiEncoding() throws IOException {
Charset charset = Charset.forName("US-ASCII");
- CxxConfiguration cxxConfig = new CxxConfiguration(charset);
+ CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/Unicode.cc", ".", "US-ASCII");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, cxxConfig, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage("Not all characters of the file can be encoded with the predefined charset " + charset.name() + ".")
.noMore();
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/FileHeaderCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/FileHeaderCheckTest.java
index 76fba8963f..32d2d4d659 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/FileHeaderCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/FileHeaderCheckTest.java
@@ -40,7 +40,7 @@ public void test() throws UnsupportedEncodingException, IOException {
check.headerFormat = "// copyright 2005";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileHeaderCheck/Class1.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
@@ -48,7 +48,7 @@ public void test() throws UnsupportedEncodingException, IOException {
check = new FileHeaderCheck();
check.headerFormat = "// copyright 20\\d\\d";
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(null);
@@ -56,48 +56,48 @@ public void test() throws UnsupportedEncodingException, IOException {
check.headerFormat = "// copyright 2005";
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileHeaderCheck/Class2.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(null).withMessage("Add or update the header of this file.");
check = new FileHeaderCheck();
check.headerFormat = "// copyright 2012";
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
check = new FileHeaderCheck();
check.headerFormat = "// copyright 2012\n// foo";
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
check = new FileHeaderCheck();
check.headerFormat = "// copyright 2012\r\n// foo";
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
check = new FileHeaderCheck();
check.headerFormat = "// copyright 2012\r// foo";
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
check = new FileHeaderCheck();
check.headerFormat = "// copyright 2012\r\r// foo";
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(null);
check = new FileHeaderCheck();
check.headerFormat = "// copyright 2012\n// foo\n\n\n\n\n\n\n\n\n\ngfoo";
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(null);
@@ -106,7 +106,7 @@ public void test() throws UnsupportedEncodingException, IOException {
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileHeaderCheck/Class3.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
}
@@ -118,12 +118,12 @@ public void regex() throws UnsupportedEncodingException, IOException {
check.isRegularExpression = true;
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileHeaderCheck/Regex1.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages()).next().atLine(null).withMessage("Add or update the header of this file.");
// Check that the regular expression is compiled once
check = new FileHeaderCheck();
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages()).next().atLine(null).withMessage("Add or update the header of this file.");
check = new FileHeaderCheck();
@@ -131,7 +131,7 @@ public void regex() throws UnsupportedEncodingException, IOException {
check.isRegularExpression = true;
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileHeaderCheck/Regex2.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages()).next().atLine(null).withMessage("Add or update the header of this file.");
check = new FileHeaderCheck();
@@ -139,7 +139,7 @@ public void regex() throws UnsupportedEncodingException, IOException {
check.isRegularExpression = true;
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileHeaderCheck/Regex3.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages()).noMore();
check = new FileHeaderCheck();
@@ -147,7 +147,7 @@ public void regex() throws UnsupportedEncodingException, IOException {
check.isRegularExpression = true;
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileHeaderCheck/Regex4.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages()).next().atLine(null).withMessage("Add or update the header of this file.");
check = new FileHeaderCheck();
@@ -155,13 +155,13 @@ public void regex() throws UnsupportedEncodingException, IOException {
check.isRegularExpression = true;
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileHeaderCheck/Regex5.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages()).noMore();
check = new FileHeaderCheck();
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileHeaderCheck/Regex6.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages()).next().atLine(null).withMessage("Add or update the header of this file.");
}
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/FileRegularExpressionCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/FileRegularExpressionCheckTest.java
index b19a0bdd9e..ad5c1ad416 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/FileRegularExpressionCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/FileRegularExpressionCheckTest.java
@@ -37,7 +37,7 @@ public void fileRegExWithoutFilePattern() throws UnsupportedEncodingException, I
check.regularExpression = "stdafx\\.h";
check.message = "Found 'stdafx.h' in file!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileRegEx.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage(check.message)
@@ -48,14 +48,14 @@ public void fileRegExWithoutFilePattern() throws UnsupportedEncodingException, I
public void fileRegExInvertWithoutFilePattern() throws UnsupportedEncodingException, IOException {
FileRegularExpressionCheck check = new FileRegularExpressionCheck();
Charset charset = Charset.forName("UTF-8");
- CxxConfiguration cxxConfig = new CxxConfiguration(charset);
+ CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
check.regularExpression = "stdafx\\.h";
check.invertRegularExpression = true;
check.message = "Found no 'stdafx.h' in file!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileRegExInvert.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, cxxConfig, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage(check.message)
.noMore();
@@ -65,13 +65,13 @@ public void fileRegExInvertWithoutFilePattern() throws UnsupportedEncodingExcept
public void fileRegExCodingErrorActionReplace() throws UnsupportedEncodingException, IOException {
FileRegularExpressionCheck check = new FileRegularExpressionCheck();
Charset charset = Charset.forName("US-ASCII");
- CxxConfiguration cxxConfig = new CxxConfiguration(charset);
+ CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
check.regularExpression = "stdafx\\.h";
check.message = "Found 'stdafx.h' in file!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileRegEx.cc", ".", "US-ASCII");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, cxxConfig, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage(check.message)
.noMore();
@@ -81,13 +81,13 @@ public void fileRegExCodingErrorActionReplace() throws UnsupportedEncodingExcept
public void fileRegExWithFilePattern() throws UnsupportedEncodingException, IOException {
FileRegularExpressionCheck check = new FileRegularExpressionCheck();
Charset charset = Charset.forName("UTF-8");
- CxxConfiguration cxxConfig = new CxxConfiguration(charset);
+ CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
check.matchFilePattern = "/**/*.cc"; // all files with .cc file extension
check.regularExpression = "#include\\s+\"stdafx\\.h\"";
check.message = "Found '#include \"stdafx.h\"' in a .cc file!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileRegEx.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, cxxConfig, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage(check.message)
@@ -98,7 +98,7 @@ public void fileRegExWithFilePattern() throws UnsupportedEncodingException, IOEx
public void fileRegExInvertWithFilePatternInvert() throws UnsupportedEncodingException, IOException {
FileRegularExpressionCheck check = new FileRegularExpressionCheck();
Charset charset = Charset.forName("UTF-8");
- CxxConfiguration cxxConfig = new CxxConfiguration(charset);
+ CxxConfiguration cxxConfig = new CxxConfiguration(charset, CxxFileTesterHelper.mockCxxLanguage());
check.matchFilePattern = "/**/*.h"; // all files with not .h file extension
check.invertFilePattern = true;
check.regularExpression = "#include\\s+\"stdafx\\.h\"";
@@ -106,7 +106,7 @@ public void fileRegExInvertWithFilePatternInvert() throws UnsupportedEncodingExc
check.message = "Found no '#include \"stdafx.h\"' in a file with not '.h' file extension!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileRegExInvert.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, cxxConfig, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, cxxConfig, tester.sensorContext, check);
CheckMessagesVerifier.verify(file.getCheckMessages())
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/FixmeTagPresenceCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/FixmeTagPresenceCheckTest.java
index 93d3cb9893..b4fb59e5e6 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/FixmeTagPresenceCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/FixmeTagPresenceCheckTest.java
@@ -36,7 +36,7 @@ public class FixmeTagPresenceCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FixmeTagPresenceCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new FixmeTagPresenceCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new FixmeTagPresenceCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(3).withMessage("Take the required action to fix the issue indicated by this comment.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/FunctionComplexityCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/FunctionComplexityCheckTest.java
index fbc4ad68b6..d2a2df19b1 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/FunctionComplexityCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/FunctionComplexityCheckTest.java
@@ -34,7 +34,7 @@ public void check() throws UnsupportedEncodingException, IOException {
FunctionComplexityCheck check = new FunctionComplexityCheck();
check.setMax(5);
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FunctionComplexity.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(13)
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/HardcodedAccountCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/HardcodedAccountCheckTest.java
index 0653fabf91..246569ef69 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/HardcodedAccountCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/HardcodedAccountCheckTest.java
@@ -41,7 +41,7 @@ public class HardcodedAccountCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/HardcodedAccount.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(6).withMessage("Do not hard code sensitive data in programs.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/HardcodedIpCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/HardcodedIpCheckTest.java
index 4747307f56..8b206b0f63 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/HardcodedIpCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/HardcodedIpCheckTest.java
@@ -41,7 +41,7 @@ public class HardcodedIpCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/HardcodedIpCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(5).withMessage("Make this IP \"0.0.0.0\" address configurable.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/LineRegularExpressionCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/LineRegularExpressionCheckTest.java
index 33393bfdfc..ffb5b2f9fc 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/LineRegularExpressionCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/LineRegularExpressionCheckTest.java
@@ -35,7 +35,7 @@ public void lineRegExWithoutFilePattern() throws UnsupportedEncodingException, I
check.regularExpression = "stdafx\\.h";
check.message = "Found 'stdafx.h' in line!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/LineRegEx.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
@@ -51,7 +51,7 @@ public void lineRegExInvertWithoutFilePattern() throws UnsupportedEncodingExcept
check.invertRegularExpression = true;
check.message = "Found no comment in the line!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/LineRegExInvert.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
@@ -67,7 +67,7 @@ public void lineRegExWithFilePattern1() throws UnsupportedEncodingException, IOE
check.message = "Found '#include \"stdafx.h\"' in line in a .cc file!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/LineRegEx.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
@@ -85,7 +85,7 @@ public void lineRegExWithFilePatternInvert() throws UnsupportedEncodingException
check.message = "Found '#include \"stdafx.h\"' in line in a not .xx file!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/LineRegEx.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(2).withMessage(check.message)
@@ -101,7 +101,7 @@ public void lineRegExWithFilePattern2() throws UnsupportedEncodingException, IOE
check.message = "Found '#include \"stdafx.h\"' in line in a .xx file!";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/LineRegEx.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/MagicNumberCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/MagicNumberCheckTest.java
index 4332272334..5ec346155c 100755
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/MagicNumberCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/MagicNumberCheckTest.java
@@ -37,7 +37,7 @@ public class MagicNumberCheckTest {
public void test() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/magicNumber.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new MagicNumberCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new MagicNumberCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
@@ -54,7 +54,7 @@ public void custom() throws UnsupportedEncodingException, IOException {
check.exceptions = "0.85 , 1,,";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/magicNumber.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(17)
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/MissingCurlyBracesCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/MissingCurlyBracesCheckTest.java
index 191b5098e4..c5d59bbdc4 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/MissingCurlyBracesCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/MissingCurlyBracesCheckTest.java
@@ -34,7 +34,7 @@ public class MissingCurlyBracesCheckTest {
@Test
public void test() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/MissingCurlyBraces.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(6).withMessage("Missing curly brace.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/MissingNewLineAtEndOfFileCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/MissingNewLineAtEndOfFileCheckTest.java
index 08a33a5da4..41d6d6cc50 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/MissingNewLineAtEndOfFileCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/MissingNewLineAtEndOfFileCheckTest.java
@@ -34,7 +34,7 @@ public class MissingNewLineAtEndOfFileCheckTest {
@Test
public void test() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/MissingNewLineAtEndOfFile.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage("Add a new line at the end of this file.")
@@ -44,7 +44,7 @@ public void test() throws UnsupportedEncodingException, IOException {
@Test
public void test2() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/EmptyFile.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage("Add a new line at the end of this file.")
.noMore();
@@ -53,7 +53,7 @@ public void test2() throws UnsupportedEncodingException, IOException {
@Test
public void test3() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/NonEmptyFile.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
}
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/NestedStatementsCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/NestedStatementsCheckTest.java
index 5c935f5f15..63ec8f7308 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/NestedStatementsCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/NestedStatementsCheckTest.java
@@ -37,7 +37,7 @@ public void detected() throws UnsupportedEncodingException, IOException {
NestedStatementsCheck check = new NestedStatementsCheck();
check.max = 5;
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/NestedStatementsCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(62)
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/NoSonarCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/NoSonarCheckTest.java
index 430ca2842d..cd678c3a01 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/NoSonarCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/NoSonarCheckTest.java
@@ -33,7 +33,7 @@ public class NoSonarCheckTest {
@Test
public void test() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/NoSonarTagPresenceCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(2).withMessage("Is //NOSONAR used to exclude false-positive or to hide real quality flaw ?")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/ParsingErrorCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/ParsingErrorCheckTest.java
index 04ec643a51..5cb25cf3e5 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/ParsingErrorCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/ParsingErrorCheckTest.java
@@ -38,11 +38,11 @@ public class ParsingErrorCheckTest {
@Test
public void test_syntax_error_recognition() throws UnsupportedEncodingException, IOException {
- CxxConfiguration config = new CxxConfiguration();
+ CxxConfiguration config = new CxxConfiguration(CxxFileTesterHelper.mockCxxLanguage());
config.setErrorRecoveryEnabled(false);
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/parsingError1.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, config, tester.sensorContext, new ParsingErrorCheck());
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, config, tester.sensorContext, new ParsingErrorCheck());
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(4).withMessageThat(containsString("Parse error"))
@@ -51,11 +51,11 @@ public void test_syntax_error_recognition() throws UnsupportedEncodingException,
@Test
public void test_syntax_error_pperror() throws UnsupportedEncodingException, IOException {
- CxxConfiguration config = new CxxConfiguration();
+ CxxConfiguration config = new CxxConfiguration(CxxFileTesterHelper.mockCxxLanguage());
config.setErrorRecoveryEnabled(false);
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/parsingError2.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, config, tester.sensorContext, new ParsingErrorCheck());
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, config, tester.sensorContext, new ParsingErrorCheck());
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(2).withMessageThat(containsString("Parse error"))
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/ParsingErrorRecoveryCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/ParsingErrorRecoveryCheckTest.java
index 68b7326a72..c719309940 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/ParsingErrorRecoveryCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/ParsingErrorRecoveryCheckTest.java
@@ -36,10 +36,10 @@ public class ParsingErrorRecoveryCheckTest {
@Test
public void test_syntax_error_recovery() throws UnsupportedEncodingException, IOException {
- CxxConfiguration config = new CxxConfiguration();
+ CxxConfiguration config = new CxxConfiguration(CxxFileTesterHelper.mockCxxLanguage());
config.setErrorRecoveryEnabled(true);
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/parsingError3.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFileConfig(tester.cxxFile, config, tester.sensorContext, new ParsingErrorRecoveryCheck());
+ SourceFile file = CxxAstScanner.scanSingleFileConfig(CxxFileTesterHelper.mockCxxLanguage(), tester.cxxFile, config, tester.sensorContext, new ParsingErrorRecoveryCheck());
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(2).withMessage("C++ Parser can't read code. Declaration is skipped.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/ReservedNamesCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/ReservedNamesCheckTest.java
index 213d9fb2ee..9eee1b3fb3 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/ReservedNamesCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/ReservedNamesCheckTest.java
@@ -35,7 +35,7 @@ public class ReservedNamesCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/ReservedNamesCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new ReservedNamesCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new ReservedNamesCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/SafetyTagCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/SafetyTagCheckTest.java
index da3ed975bc..d3d01d8dde 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/SafetyTagCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/SafetyTagCheckTest.java
@@ -35,7 +35,7 @@ public void test() throws UnsupportedEncodingException, IOException {
check.suffix = "_SAFETY";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/SafetyTagCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(21).withMessage("Source files implementing risk mitigations shall use special name suffix '_SAFETY' : MyRimName");
@@ -46,7 +46,7 @@ public void test() throws UnsupportedEncodingException, IOException {
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/SafetyTagCheck_SAFETY.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
@@ -56,7 +56,7 @@ public void test() throws UnsupportedEncodingException, IOException {
check.suffix = "_SAFETY";
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/SafetyTagCheck_SAFETY.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
@@ -64,7 +64,7 @@ public void test() throws UnsupportedEncodingException, IOException {
check.regularExpression = "@hazard";
tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/SafetyTagCheck_SAFETY.cc", ".");
- file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
}
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/StringLiteralDuplicatedCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/StringLiteralDuplicatedCheckTest.java
index 87deb771b9..e21699a85b 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/StringLiteralDuplicatedCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/StringLiteralDuplicatedCheckTest.java
@@ -35,7 +35,7 @@ public class StringLiteralDuplicatedCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/StringLiteralDuplicatedCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new StringLiteralDuplicatedCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new StringLiteralDuplicatedCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(12).withMessage("Define a constant instead of duplicating this literal \"bbbbb\" 2 times.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/SwitchLastCaseIsDefaultCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/SwitchLastCaseIsDefaultCheckTest.java
index 32c9f97276..594d4af8d3 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/SwitchLastCaseIsDefaultCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/SwitchLastCaseIsDefaultCheckTest.java
@@ -35,7 +35,7 @@ public class SwitchLastCaseIsDefaultCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/SwitchLastCaseIsDefaultCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new SwitchLastCaseIsDefaultCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new SwitchLastCaseIsDefaultCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/TabCharacterCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/TabCharacterCheckTest.java
index 5371284ce8..ed4db64cf1 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/TabCharacterCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/TabCharacterCheckTest.java
@@ -35,7 +35,7 @@ public void fileWithTabsOneMessagePerFile() throws UnsupportedEncodingException,
check.createLineViolation = false;
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TabCharacter.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage("Replace all tab characters in this file by sequences of white-spaces.")
@@ -46,7 +46,7 @@ public void fileWithTabsOneMessagePerFile() throws UnsupportedEncodingException,
public void fileWithTabsOneMessagePerLine() throws UnsupportedEncodingException, IOException {
check.createLineViolation = true;
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TabCharacter.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(3).withMessage("Replace all tab characters in this line by sequences of white-spaces.")
@@ -58,7 +58,7 @@ public void fileWithTabsOneMessagePerLine() throws UnsupportedEncodingException,
public void fileWithoutTabs() throws UnsupportedEncodingException, IOException {
check.createLineViolation = false;
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/NonEmptyFile.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/TodoTagPresenceCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/TodoTagPresenceCheckTest.java
index 71a1dadb2a..0cfc4b1799 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/TodoTagPresenceCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/TodoTagPresenceCheckTest.java
@@ -35,7 +35,7 @@ public class TodoTagPresenceCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TodoTagPresenceCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new TodoTagPresenceCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new TodoTagPresenceCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(3).withMessage("Complete the task associated to this TODO comment.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooLongLineCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooLongLineCheckTest.java
index fe4601b673..2883bc6739 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooLongLineCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooLongLineCheckTest.java
@@ -34,7 +34,7 @@ public class TooLongLineCheckTest {
public void test() throws UnsupportedEncodingException, IOException {
check.maximumLineLength = 20;
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/LineLength.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(5).withMessage("Split this 28 characters long line (which is greater than 20 authorized).")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyLinesOfCodeInFileCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyLinesOfCodeInFileCheckTest.java
index 49208e8fe0..d1576c8cb8 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyLinesOfCodeInFileCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyLinesOfCodeInFileCheckTest.java
@@ -34,7 +34,7 @@ public class TooManyLinesOfCodeInFileCheckTest {
public void test() throws UnsupportedEncodingException, IOException {
check.setMax(1);
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/complexity.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage("This file has 22 lines of code, which is greater than 1 authorized. Split it into smaller files.")
@@ -44,7 +44,7 @@ public void test() throws UnsupportedEncodingException, IOException {
@Test
public void test2() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/complexity.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyLinesOfCodeInFunctionCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyLinesOfCodeInFunctionCheckTest.java
index 9ddf56b62e..6f54bc204a 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyLinesOfCodeInFunctionCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyLinesOfCodeInFunctionCheckTest.java
@@ -32,7 +32,7 @@ public class TooManyLinesOfCodeInFunctionCheckTest {
public void test() throws UnsupportedEncodingException, IOException {
check.setMax(6);
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FunctionLength.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(21)
.noMore();
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyParametersCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyParametersCheckTest.java
index 67857e1621..5e88885f11 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyParametersCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyParametersCheckTest.java
@@ -36,7 +36,7 @@ public void test() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TooManyParameters.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(11)
.next().atLine(16)
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyStatementsPerLineCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyStatementsPerLineCheckTest.java
index ac5470fe01..677567ac43 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyStatementsPerLineCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/TooManyStatementsPerLineCheckTest.java
@@ -36,7 +36,7 @@ public void test() throws UnsupportedEncodingException, IOException {
check.excludeCaseBreak = false;
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TooManyStatementsPerLine.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(17).withMessage("At most one statement is allowed per line, but 2 statements were found on this line.")
@@ -60,7 +60,7 @@ public void testExcludeCaseBreak() throws UnsupportedEncodingException, IOExcept
check.excludeCaseBreak = true;
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/TooManyStatementsPerLine.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(17).withMessage("At most one statement is allowed per line, but 2 statements were found on this line.")
.next().atLine(20)
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/UndocumentedApiCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/UndocumentedApiCheckTest.java
index b98415a0e0..c51d1d18f1 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/UndocumentedApiCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/UndocumentedApiCheckTest.java
@@ -39,7 +39,7 @@ public class UndocumentedApiCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/UndocumentedApiCheck/no_doc.h", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new UndocumentedApiCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new UndocumentedApiCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(6) // class
@@ -100,7 +100,7 @@ public void detected() throws UnsupportedEncodingException, IOException {
@Test
public void docStyle1() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/UndocumentedApiCheck/doc_style1.h", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new UndocumentedApiCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new UndocumentedApiCheck());
StringBuilder errors = new StringBuilder();
for (CheckMessage msg : file.getCheckMessages()) {
@@ -118,7 +118,7 @@ public void docStyle1() throws UnsupportedEncodingException, IOException {
@Test
public void docStyle2() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/UndocumentedApiCheck/doc_style2.h", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new UndocumentedApiCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new UndocumentedApiCheck());
StringBuilder errors = new StringBuilder();
for (CheckMessage msg : file.getCheckMessages()) {
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/UnnamedNamespaceInHeaderCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/UnnamedNamespaceInHeaderCheckTest.java
index 8bff9c8c2c..63a28e49e5 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/UnnamedNamespaceInHeaderCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/UnnamedNamespaceInHeaderCheckTest.java
@@ -33,7 +33,7 @@ public void check() throws UnsupportedEncodingException, IOException {
UnnamedNamespaceInHeaderCheck check = new UnnamedNamespaceInHeaderCheck();
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/UnnamedNamespaceInHeader.h", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().withMessage("Unnamed namespaces are not allowed in header files.");
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/UseCorrectTypeCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/UseCorrectTypeCheckTest.java
index ccf4d95072..3a9bd686ef 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/UseCorrectTypeCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/UseCorrectTypeCheckTest.java
@@ -35,7 +35,7 @@ public class UseCorrectTypeCheckTest {
@Test
public void detected() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/UseCorrectTypesCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new UseCorrectTypeCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new UseCorrectTypeCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(7).withMessage("Use the correct type instead of NULL (1 times).")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/UselessParenthesesCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/UselessParenthesesCheckTest.java
index 3edb90ae5b..7ba520b9d7 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/UselessParenthesesCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/UselessParenthesesCheckTest.java
@@ -34,7 +34,7 @@ public class UselessParenthesesCheckTest {
@Test
public void detected() throws IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/UselessParenthesesCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, new UselessParenthesesCheck());
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), new UselessParenthesesCheck());
checkMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(4).withMessage("Remove those useless parentheses.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/UsingNamespaceInHeaderCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/UsingNamespaceInHeaderCheckTest.java
index d8da38fc18..f4604f0985 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/UsingNamespaceInHeaderCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/UsingNamespaceInHeaderCheckTest.java
@@ -33,7 +33,7 @@ public void check() throws UnsupportedEncodingException, IOException {
UsingNamespaceInHeaderCheck check = new UsingNamespaceInHeaderCheck();
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/UsingNamespaceInHeader.h", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(11).withMessage("Using namespace are not allowed in header files.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/WrongIncludeCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/WrongIncludeCheckTest.java
index e847dcb379..299c154f46 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/WrongIncludeCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/WrongIncludeCheckTest.java
@@ -33,7 +33,7 @@ public void check() throws UnsupportedEncodingException, IOException {
UseCorrectIncludeCheck check = new UseCorrectIncludeCheck();
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/UseCorrectIncludeCheck.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(2).withMessage("Do not use relative path for #include directive.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/XPathCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/XPathCheckTest.java
index e88f02e57e..270e0dcb1d 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/XPathCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/XPathCheckTest.java
@@ -36,7 +36,7 @@ public void xpathWithoutFilePattern() throws UnsupportedEncodingException, IOExc
check.message = "Avoid declarations!! ";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/xpath.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(1).withMessage(check.message)
.noMore();
@@ -50,7 +50,7 @@ public void xpathWithFilePattern1() throws UnsupportedEncodingException, IOExcep
check.message = "Avoid declarations!! ";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/xpath.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(1).withMessage(check.message)
.noMore();
@@ -64,7 +64,7 @@ public void xpathWithFilePattern2() throws UnsupportedEncodingException, IOExcep
check.message = "Avoid declarations!! ";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/xpath.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(1).withMessage(check.message)
.noMore();
@@ -78,7 +78,7 @@ public void xpathWithFilePattern3() throws UnsupportedEncodingException, IOExcep
check.message = "Avoid declarations!! ";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/xpath.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.noMore();
}
@@ -92,7 +92,7 @@ public void xpathWithFilePatternInvert() throws UnsupportedEncodingException, IO
check.message = "Avoid declarations!! ";
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/xpath.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(1).withMessage(check.message)
.noMore();
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/ClassNameCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/ClassNameCheckTest.java
index eb8a0670d8..558b8b53f9 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/ClassNameCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/ClassNameCheckTest.java
@@ -34,7 +34,7 @@ public void test() throws Exception {
ClassNameCheck check = new ClassNameCheck();
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/ClassName.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(3).withMessage(
"Rename class \"MyClass_WithNotCompliantName1\" to match the regular expression ^[A-Z_][a-zA-Z0-9]+$.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/FileNameCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/FileNameCheckTest.java
index 9b13186a20..04f9abca5a 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/FileNameCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/FileNameCheckTest.java
@@ -39,7 +39,7 @@ public class FileNameCheckTest {
@Test
public void bad_name() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/badFile_name.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
String format = "(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$";
String message = "Rename this file to match this regular expression: \"%s\".";
@@ -50,7 +50,7 @@ public void bad_name() throws UnsupportedEncodingException, IOException {
@Test
public void good_name_camel_case() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FileName.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
checkMessagesVerifier.verify(file.getCheckMessages());
}
@@ -58,7 +58,7 @@ public void good_name_camel_case() throws UnsupportedEncodingException, IOExcept
@Test
public void good_name_snake_case() throws UnsupportedEncodingException, IOException {
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/file_name.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
checkMessagesVerifier.verify(file.getCheckMessages());
}
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/FunctionNameCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/FunctionNameCheckTest.java
index 946fa5c027..635e12b71d 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/FunctionNameCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/FunctionNameCheckTest.java
@@ -34,7 +34,7 @@ public void test() throws Exception {
FunctionNameCheck check = new FunctionNameCheck();
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/FunctionName.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(8).withMessage(
"Rename function \"Badly_Named_Function\" to match the regular expression ^[a-z_][a-z0-9_]{2,30}$.")
diff --git a/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/MethodNameCheckTest.java b/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/MethodNameCheckTest.java
index db9ce9baef..a9378fa84e 100644
--- a/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/MethodNameCheckTest.java
+++ b/cxx-checks/src/test/java/org/sonar/cxx/checks/naming/MethodNameCheckTest.java
@@ -33,7 +33,7 @@ public class MethodNameCheckTest {
public void test() throws Exception {
MethodNameCheck check = new MethodNameCheck();
CxxFileTester tester = CxxFileTesterHelper.CreateCxxFileTester("src/test/resources/checks/MethodName.cc", ".");
- SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, check);
+ SourceFile file = CxxAstScanner.scanSingleFile(tester.cxxFile, tester.sensorContext, CxxFileTesterHelper.mockCxxLanguage(), check);
CheckMessagesVerifier.verify(file.getCheckMessages())
.next().atLine(12).withMessage(
"Rename method \"Badly_Named_Method2\" to match the regular expression ^[A-Z][A-Za-z0-9]{2,30}$.")
diff --git a/cxx-lint/src/main/java/org/sonar/cxx/cxxlint/CppLanguage.java b/cxx-lint/src/main/java/org/sonar/cxx/cxxlint/CppLanguage.java
new file mode 100644
index 0000000000..3cc020273f
--- /dev/null
+++ b/cxx-lint/src/main/java/org/sonar/cxx/cxxlint/CppLanguage.java
@@ -0,0 +1,55 @@
+/*
+ * Sonar C++ Plugin (Community)
+ * Copyright (C) 2010-2017 SonarOpenCommunity
+ * http://github.com/SonarOpenCommunity/sonar-cxx
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.cxx.cxxlint;
+
+import org.sonar.api.config.Settings;
+import org.sonar.cxx.CxxLanguage;
+
+/**
+ *
+ * @author jocs
+ */
+public class CppLanguage extends CxxLanguage {
+
+ public CppLanguage() {
+ super("c++", new Settings());
+ }
+
+ @Override
+ public String[] getFileSuffixes() {
+ return new String [] {"cpp", "hpp", "h", "hxx", "cxx"};
+ }
+
+ @Override
+ public String[] getSourceFileSuffixes() {
+ return new String [] {"cpp", "cxx"};
+ }
+
+ @Override
+ public String[] getHeaderFileSuffixes() {
+ return new String [] {"hpp", "h", "hxx"};
+ }
+
+ @Override
+ public String getPropertiesKey() {
+ return "cxx";
+ }
+}
diff --git a/cxx-lint/src/main/java/org/sonar/cxx/cxxlint/CxxLint.java b/cxx-lint/src/main/java/org/sonar/cxx/cxxlint/CxxLint.java
index 589b65f574..d800ad36f8 100644
--- a/cxx-lint/src/main/java/org/sonar/cxx/cxxlint/CxxLint.java
+++ b/cxx-lint/src/main/java/org/sonar/cxx/cxxlint/CxxLint.java
@@ -135,7 +135,7 @@ public static void main(String[] args)
throw exp;
}
- CxxConfiguration configuration = new CxxConfiguration(Charset.forName(encodingOfFile));
+ CxxConfiguration configuration = new CxxConfiguration(Charset.forName(encodingOfFile), new CppLanguage());
String fileName = new File(fileToAnalyse).getName();
SensorContextTester sensorContext = SensorContextTester.create(new File(fileToAnalyse).getParentFile().toPath());
@@ -279,9 +279,9 @@ public static void main(String[] args)
}
System.out.println("Analyse with : " + visitors.size() + " checks");
-
SourceFile file = CxxAstScanner.scanSingleFileConfig(
+ new CppLanguage(),
cxxFile,
configuration,
sensorContext,
diff --git a/cxx-sensors/pom.xml b/cxx-sensors/pom.xml
new file mode 100644
index 0000000000..4d04f66809
--- /dev/null
+++ b/cxx-sensors/pom.xml
@@ -0,0 +1,105 @@
+
+
+ 4.0.0
+
+
+ org.sonarsource.sonarqube-plugins.cxx
+ cxx
+ 0.9.8-SNAPSHOT
+
+
+ cxx-sensors
+ Cxx :: Sensors
+
+
+ target/${project.artifactId}-${project.version}.jar
+
+
+
+
+ org.sonarsource.sonarqube
+ sonar-plugin-api
+ provided
+
+
+
+ org.sonarsource.dotnet
+ sonar-dotnet-tests-library
+
+
+
+ ${project.groupId}
+ cxx-squid
+ ${project.version}
+
+
+ ${project.groupId}
+ cxx-checks
+ ${project.version}
+
+
+
+ org.sonarsource.sslr
+ sslr-testing-harness
+ test
+
+
+
+ org.apache.maven
+ maven-project
+ 2.0.9
+ test
+
+
+ org.sonarsource.sonarqube
+ sonar-testing-harness
+ test
+
+
+
+ org.apache.ant
+ ant
+
+
+ jdom
+ jdom
+
+
+ org.mockito
+ mockito-all
+ test
+
+
+ ch.qos.logback
+ logback-classic
+ test
+
+
+ com.google.guava
+ guava
+ 10.0.1
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+ commons-lang
+ commons-lang
+ 2.6
+ jar
+
+
+ com.fasterxml.jackson.core
+ jackson-core
+ 2.8.6
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.8.6
+
+
+
+
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/clangtidy/CxxClangTidyRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidyRuleRepository.java
similarity index 75%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/clangtidy/CxxClangTidyRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidyRuleRepository.java
index 6b3edac6a8..936560332d 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/clangtidy/CxxClangTidyRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidyRuleRepository.java
@@ -17,27 +17,28 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.clangtidy;
+package org.sonar.cxx.sensors.clangtidy;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
-import org.sonar.plugins.cxx.utils.CxxAbstractRuleRepository;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxAbstractRuleRepository;
/**
* {@inheritDoc}
*/
-public final class CxxClangTidyRuleRepository extends CxxAbstractRuleRepository {
+public class CxxClangTidyRuleRepository extends CxxAbstractRuleRepository {
public static final String KEY = "ClangTidy";
- public static final String CUSTOM_RULES_KEY = "sonar.cxx.clangtidy.customRules";
+ public static final String CUSTOM_RULES_KEY = "clangtidy.customRules";
private static final String NAME = "Clang-Tidy";
/**
* {@inheritDoc}
*/
- public CxxClangTidyRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
- super(fileSystem, xmlRuleLoader, settings, KEY, NAME, CUSTOM_RULES_KEY);
+ public CxxClangTidyRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
+ super(fileSystem, xmlRuleLoader, KEY, NAME, CUSTOM_RULES_KEY, language);
}
@Override
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/clangtidy/CxxClangTidySensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidySensor.java
similarity index 86%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/clangtidy/CxxClangTidySensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidySensor.java
index 4e1d71fda0..a5f6afead8 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/clangtidy/CxxClangTidySensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/CxxClangTidySensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.clangtidy;
+package org.sonar.cxx.sensors.clangtidy;
import java.io.File;
import java.util.Scanner;
@@ -27,25 +27,24 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
/**
* Sensor for clang-tidy
*/
public class CxxClangTidySensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxClangTidySensor.class);
- public static final String REPORT_PATH_KEY = "sonar.cxx.clangtidy.reportPath";
+ public static final String KEY = "Clang-Tidy";
+ public static final String REPORT_PATH_KEY = "clangtidy.reportPath";
/**
* {@inheritDoc}
*/
- public CxxClangTidySensor(Settings settings) {
- super(settings, CxxMetrics.CLANGTIDY);
+ public CxxClangTidySensor(CxxLanguage language) {
+ super(language);
}
@Override
@@ -55,7 +54,7 @@ protected String reportPathKey() {
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxClangTidySensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxClangTidySensor");
}
@Override
@@ -90,4 +89,9 @@ protected void processReport(final SensorContext context, File report) {
LOG.error("Failed to parse clang-tidy report: {}", e);
}
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/clangtidy/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/clangtidy/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/package-info.java
index d3a4fb8b3e..96725cb928 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/clangtidy/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/clangtidy/package-info.java
@@ -21,6 +21,6 @@
* Package with sensor to evaluate clang-tidy reports.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.clangtidy;
+package org.sonar.cxx.sensors.clangtidy;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CompilerParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CompilerParser.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CompilerParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CompilerParser.java
index f59339883b..b5b8e4df95 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CompilerParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CompilerParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.compiler;
+package org.sonar.cxx.sensors.compiler;
import java.io.File;
import java.util.List;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerGccParser.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerGccParser.java
index fa24517802..9b8a9d89e6 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerGccParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.compiler;
+package org.sonar.cxx.sensors.compiler;
import java.io.File;
import java.util.List;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerGccRuleRepository.java
similarity index 75%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerGccRuleRepository.java
index 9ff9d7b1e3..9f7543babf 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerGccRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerGccRuleRepository.java
@@ -17,27 +17,28 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.compiler;
+package org.sonar.cxx.sensors.compiler;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
-import org.sonar.plugins.cxx.utils.CxxAbstractRuleRepository;
+import org.sonar.cxx.sensors.utils.CxxAbstractRuleRepository;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
+import org.sonar.cxx.CxxLanguage;
/**
* {@inheritDoc}
*/
-public final class CxxCompilerGccRuleRepository extends CxxAbstractRuleRepository {
+public class CxxCompilerGccRuleRepository extends CxxAbstractRuleRepository {
static final String KEY = "compiler-gcc";
- public static final String CUSTOM_RULES_KEY = "sonar.cxx.compiler-gcc.customRules";
+ public static final String CUSTOM_RULES_KEY = "compiler-gcc.customRules";
private static final String NAME = "Compiler-GCC";
/**
* {@inheritDoc}
*/
- public CxxCompilerGccRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
- super(fileSystem, xmlRuleLoader, settings, KEY, NAME, CUSTOM_RULES_KEY);
+ public CxxCompilerGccRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
+ super(fileSystem, xmlRuleLoader, KEY, NAME, CUSTOM_RULES_KEY, language);
}
@Override
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerSensor.java
similarity index 85%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerSensor.java
index 97a135a982..cc17cb61be 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.compiler;
+package org.sonar.cxx.sensors.compiler;
import java.io.File;
import java.util.HashMap;
@@ -27,12 +27,10 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
/**
* compiler for C++ with advanced analysis features (e.g. for VC 2008 team
@@ -42,20 +40,22 @@
*/
public class CxxCompilerSensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxCompilerSensor.class);
- public static final String REPORT_PATH_KEY = "sonar.cxx.compiler.reportPath";
- public static final String REPORT_REGEX_DEF = "sonar.cxx.compiler.regex";
- public static final String REPORT_CHARSET_DEF = "sonar.cxx.compiler.charset";
- public static final String PARSER_KEY_DEF = "sonar.cxx.compiler.parser";
+ public static final String REPORT_PATH_KEY = "compiler.reportPath";
+ public static final String REPORT_REGEX_DEF = "compiler.regex";
+ public static final String REPORT_CHARSET_DEF = "compiler.charset";
+ public static final String PARSER_KEY_DEF = "compiler.parser";
public static final String DEFAULT_PARSER_DEF = CxxCompilerVcParser.KEY;
public static final String DEFAULT_CHARSET_DEF = "UTF-8";
+ public static final String KEY = "Compiler";
private final Map parsers = new HashMap<>();
/**
* {@inheritDoc}
*/
- public CxxCompilerSensor(Settings settings) {
- super(settings, CxxMetrics.COMPILER);
+ public CxxCompilerSensor(CxxLanguage language) {
+ super(language);
+
addCompilerParser(new CxxCompilerVcParser());
addCompilerParser(new CxxCompilerGccParser());
}
@@ -82,7 +82,7 @@ protected CompilerParser getCompilerParser() {
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxCompilerSensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxCompilerSensor");
}
@Override
@@ -134,4 +134,9 @@ protected void processReport(final SensorContext context, File report)
private boolean isInputValid(CompilerParser.Warning warning) {
return warning != null && !warning.toString().isEmpty();
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerVcParser.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerVcParser.java
index e4fded08f9..12705cec22 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerVcParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.compiler;
+package org.sonar.cxx.sensors.compiler;
import java.io.File;
import java.util.List;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerVcRuleRepository.java
similarity index 75%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerVcRuleRepository.java
index a949a5d223..53e69bcd44 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/CxxCompilerVcRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/CxxCompilerVcRuleRepository.java
@@ -17,27 +17,28 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.compiler;
+package org.sonar.cxx.sensors.compiler;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
-import org.sonar.plugins.cxx.utils.CxxAbstractRuleRepository;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxAbstractRuleRepository;
/**
* {@inheritDoc}
*/
-public final class CxxCompilerVcRuleRepository extends CxxAbstractRuleRepository {
+public class CxxCompilerVcRuleRepository extends CxxAbstractRuleRepository {
public static final String KEY = "compiler-vc";
- public static final String CUSTOM_RULES_KEY = "sonar.cxx.compiler-vc.customRules";
+ public static final String CUSTOM_RULES_KEY = "compiler-vc.customRules";
private static final String NAME = "Compiler-VC";
/**
* {@inheritDoc}
*/
- public CxxCompilerVcRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
- super(fileSystem, xmlRuleLoader, settings, KEY, NAME, CUSTOM_RULES_KEY);
+ public CxxCompilerVcRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
+ super(fileSystem, xmlRuleLoader, KEY, NAME, CUSTOM_RULES_KEY, language);
}
@Override
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/package-info.java
index 05eca51196..f816f182d0 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/compiler/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/compiler/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate compiler specific report files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.compiler;
+package org.sonar.cxx.sensors.compiler;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/BullseyeParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/BullseyeParser.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/BullseyeParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/BullseyeParser.java
index 9941697a12..6402104758 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/BullseyeParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/BullseyeParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
import java.io.File;
import java.util.Iterator;
@@ -32,7 +32,7 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.sensors.utils.StaxParser;
/**
* {@inheritDoc}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoberturaParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoberturaParser.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoberturaParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoberturaParser.java
index 638a7f0f27..b3fc22dc47 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoberturaParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoberturaParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
import java.io.File;
import java.util.Map;
@@ -31,8 +31,8 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.utils.CxxUtils;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.sensors.utils.CxxUtils;
+import org.sonar.cxx.sensors.utils.StaxParser;
/**
* {@inheritDoc}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoverageMeasure.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasure.java
similarity index 93%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoverageMeasure.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasure.java
index b65a9d4368..c278d43ff8 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoverageMeasure.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasure.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
/**
*
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoverageMeasures.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasures.java
similarity index 95%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoverageMeasures.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasures.java
index cc1821a8ed..4211acf4b6 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoverageMeasures.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageMeasures.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
import java.util.Collection;
import java.util.HashMap;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoverageParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageParser.java
similarity index 97%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoverageParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageParser.java
index be2e1a1e07..4720a9788d 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CoverageParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CoverageParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
import java.io.File;
import java.util.Map;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CxxCoverageCache.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CxxCoverageCache.java
similarity index 94%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CxxCoverageCache.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CxxCoverageCache.java
index 8a100d4803..cccc8583b2 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CxxCoverageCache.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CxxCoverageCache.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
import java.lang.annotation.Annotation;
import java.util.HashMap;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CxxCoverageParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CxxCoverageParser.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CxxCoverageParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CxxCoverageParser.java
index 11116f56f1..563ceca1a6 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CxxCoverageParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CxxCoverageParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
/**
* The base class for coverage report parsers
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CxxCoverageSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CxxCoverageSensor.java
similarity index 83%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CxxCoverageSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CxxCoverageSensor.java
index bafb973b5c..c95a7e577a 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/CxxCoverageSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/CxxCoverageSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
import java.io.File;
import java.util.Collection;
@@ -37,31 +37,31 @@
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.batch.sensor.coverage.NewCoverage;
import org.sonar.api.batch.sensor.coverage.CoverageType;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
-import org.sonar.plugins.cxx.utils.CxxUtils;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
+import org.sonar.cxx.sensors.utils.CxxUtils;
/**
* {@inheritDoc}
*/
public class CxxCoverageSensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxCoverageSensor.class);
- public static final String REPORT_PATH_KEY = "sonar.cxx.coverage.reportPath";
- public static final String IT_REPORT_PATH_KEY = "sonar.cxx.coverage.itReportPath";
- public static final String OVERALL_REPORT_PATH_KEY = "sonar.cxx.coverage.overallReportPath";
- public static final String FORCE_ZERO_COVERAGE_KEY = "sonar.cxx.coverage.forceZeroCoverage";
+ public static final String REPORT_PATH_KEY = "coverage.reportPath";
+ public static final String IT_REPORT_PATH_KEY = "coverage.itReportPath";
+ public static final String OVERALL_REPORT_PATH_KEY = "coverage.overallReportPath";
+ public static final String FORCE_ZERO_COVERAGE_KEY = "coverage.forceZeroCoverage";
private final List parsers = new LinkedList<>();
private final CxxCoverageCache cache;
+ public static final String KEY = "Coverage";
/**
* {@inheritDoc}
*/
- public CxxCoverageSensor(Settings settings, CxxCoverageCache cache) {
- super(settings, null);
+ public CxxCoverageSensor(CxxCoverageCache cache, CxxLanguage language) {
+ super(language);
this.cache = cache;
parsers.add(new CoberturaParser());
parsers.add(new BullseyeParser());
@@ -70,7 +70,7 @@ public CxxCoverageSensor(Settings settings, CxxCoverageCache cache) {
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxCoverageSensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxCoverageSensor");
}
/**
@@ -82,30 +82,30 @@ public void execute(SensorContext context, Map> linesOfC
Map itCoverageMeasures = null;
Map overallCoverageMeasures = null;
- LOG.debug("Coverage BaseDir '{}' ", context.fileSystem().baseDir());
+ LOG.debug("Coverage BaseDir '{}' ", context.fileSystem().baseDir());
- if (settings.hasKey(REPORT_PATH_KEY)) {
+ if (this.language.hasKey(REPORT_PATH_KEY)) {
LOG.debug("Parsing coverage reports");
- List reports = getReports(settings, context.fileSystem().baseDir(), REPORT_PATH_KEY);
+ List reports = getReports(this.language, context.fileSystem().baseDir(), REPORT_PATH_KEY);
coverageMeasures = processReports(context, reports, this.cache.unitCoverageCache());
saveMeasures(context, coverageMeasures, CoverageType.UNIT);
}
- if (settings.hasKey(IT_REPORT_PATH_KEY)) {
+ if (this.language.hasKey(IT_REPORT_PATH_KEY)) {
LOG.debug("Parsing integration test coverage reports");
- List itReports = getReports(settings, context.fileSystem().baseDir(), IT_REPORT_PATH_KEY);
+ List itReports = getReports(this.language, context.fileSystem().baseDir(), IT_REPORT_PATH_KEY);
itCoverageMeasures = processReports(context, itReports, this.cache.integrationCoverageCache());
saveMeasures(context, itCoverageMeasures, CoverageType.IT);
}
- if (settings.hasKey(OVERALL_REPORT_PATH_KEY)) {
+ if (this.language.hasKey(OVERALL_REPORT_PATH_KEY)) {
LOG.debug("Parsing overall test coverage reports");
- List overallReports = getReports(settings, context.fileSystem().baseDir(), OVERALL_REPORT_PATH_KEY);
+ List overallReports = getReports(this.language, context.fileSystem().baseDir(), OVERALL_REPORT_PATH_KEY);
overallCoverageMeasures = processReports(context, overallReports, this.cache.overallCoverageCache());
saveMeasures(context, overallCoverageMeasures, CoverageType.OVERALL);
}
- if (settings.getBoolean(FORCE_ZERO_COVERAGE_KEY)) {
+ if (this.language.getBooleanOption(FORCE_ZERO_COVERAGE_KEY)) {
LOG.debug("Zeroing coverage information for untouched files");
zeroMeasuresWithoutReports(context, coverageMeasures, itCoverageMeasures, overallCoverageMeasures, linesOfCode);
}
@@ -120,7 +120,7 @@ private void zeroMeasuresWithoutReports(
) {
FileSystem fileSystem = context.fileSystem();
FilePredicates p = fileSystem.predicates();
- Iterable inputFiles = fileSystem.inputFiles(p.and(p.hasType(InputFile.Type.MAIN), p.hasLanguage(CxxLanguage.KEY)));
+ Iterable inputFiles = fileSystem.inputFiles(p.and(p.hasType(InputFile.Type.MAIN), p.hasLanguage(this.language.getKey())));
for (InputFile inputFile : inputFiles) {
Set linesOfCodeForFile = linesOfCode.get(inputFile);
@@ -153,7 +153,7 @@ private void saveZeroValueForResource(InputFile inputFile, SensorContext context
newCoverage.lineHits(line, 0);
} catch (Exception ex) {
LOG.error("Cannot save Line Hits for Line '{}' '{}' : '{}', ignoring measure", inputFile.relativePath(), line, ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
}
@@ -161,7 +161,7 @@ private void saveZeroValueForResource(InputFile inputFile, SensorContext context
newCoverage.save();
} catch (Exception ex) {
LOG.error("Cannot save measure '{}' : '{}', ignoring measure", inputFile.relativePath(), ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
}
}
@@ -225,7 +225,7 @@ private void saveMeasures(SensorContext context,
newCoverage.lineHits(measure.getLine(), measure.getHits());
} catch(Exception ex) {
LOG.error("Cannot save Line Hits for Line '{}' '{}' : '{}', ignoring measure", filePath, measure.getLine(), ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
}
@@ -235,7 +235,7 @@ private void saveMeasures(SensorContext context,
newCoverage.conditions(measure.getLine(), measure.getConditions(), measure.getCoveredConditions());
} catch(Exception ex) {
LOG.error("Cannot save Conditions Hits for Line '{}' '{}' : '{}', ignoring measure", filePath, measure.getLine(), ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
}
}
@@ -245,11 +245,21 @@ private void saveMeasures(SensorContext context,
newCoverage.save();
} catch(Exception ex) {
LOG.error("Cannot save measure '{}' : '{}', ignoring measure", filePath, ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
} else {
LOG.debug("Cannot find the file '{}', ignoring coverage measures", filePath);
}
}
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
+
+ @Override
+ protected String reportPathKey() {
+ return REPORT_PATH_KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/VisualStudioParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/VisualStudioParser.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/VisualStudioParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/VisualStudioParser.java
index 8a85253d97..23e9f87b76 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/VisualStudioParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/VisualStudioParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
import java.io.File;
import java.util.Map;
@@ -29,7 +29,7 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.sensors.utils.StaxParser;
/**
* {@inheritDoc}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/package-info.java
index a3e12ca684..d7fef8a2fe 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/coverage/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/coverage/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate coverage tool specific report files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.coverage;
+package org.sonar.cxx.sensors.coverage;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CppcheckParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CppcheckParser.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CppcheckParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CppcheckParser.java
index ec676bbbe1..9ede38445c 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CppcheckParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CppcheckParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.cppcheck;
+package org.sonar.cxx.sensors.cppcheck;
import java.io.File;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CppcheckParserV1.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CppcheckParserV1.java
similarity index 95%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CppcheckParserV1.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CppcheckParserV1.java
index 8da18f78ba..f164ba734c 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CppcheckParserV1.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CppcheckParserV1.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.cppcheck;
+package org.sonar.cxx.sensors.cppcheck;
import java.io.File;
@@ -27,8 +27,8 @@
import org.codehaus.staxmate.in.SMInputCursor;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.utils.EmptyReportException;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.sensors.utils.EmptyReportException;
+import org.sonar.cxx.sensors.utils.StaxParser;
/**
* {@inheritDoc}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CppcheckParserV2.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CppcheckParserV2.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CppcheckParserV2.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CppcheckParserV2.java
index 27ad27ba1a..f0a1c689f1 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CppcheckParserV2.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CppcheckParserV2.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.cppcheck;
+package org.sonar.cxx.sensors.cppcheck;
import java.io.File;
@@ -28,8 +28,8 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.utils.EmptyReportException;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.sensors.utils.EmptyReportException;
+import org.sonar.cxx.sensors.utils.StaxParser;
/**
* {@inheritDoc}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CxxCppCheckRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CxxCppCheckRuleRepository.java
similarity index 74%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CxxCppCheckRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CxxCppCheckRuleRepository.java
index 3d5c1074d3..2c64b7a268 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CxxCppCheckRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CxxCppCheckRuleRepository.java
@@ -17,27 +17,27 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.cppcheck;
+package org.sonar.cxx.sensors.cppcheck;
-import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
-import org.sonar.plugins.cxx.utils.CxxAbstractRuleRepository;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxAbstractRuleRepository;
/**
* {@inheritDoc}
*/
-public final class CxxCppCheckRuleRepository extends CxxAbstractRuleRepository {
+public class CxxCppCheckRuleRepository extends CxxAbstractRuleRepository {
public static final String KEY = "cppcheck";
- public static final String CUSTOM_RULES_KEY = "sonar.cxx.cppcheck.customRules";
+ public static final String CUSTOM_RULES_KEY = "cppcheck.customRules";
private static final String NAME = "Cppcheck";
/**
* {@inheritDoc}
*/
- public CxxCppCheckRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
- super(fileSystem, xmlRuleLoader, settings, KEY, NAME, CUSTOM_RULES_KEY);
+ public CxxCppCheckRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
+ super(fileSystem, xmlRuleLoader, KEY, NAME, CUSTOM_RULES_KEY, language);
}
@Override
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CxxCppCheckSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CxxCppCheckSensor.java
similarity index 83%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CxxCppCheckSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CxxCppCheckSensor.java
index 82a94064da..bd7d0b5f8b 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/CxxCppCheckSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/CxxCppCheckSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.cppcheck;
+package org.sonar.cxx.sensors.cppcheck;
import java.io.File;
import java.util.LinkedList;
@@ -27,12 +27,10 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
/**
* Sensor for cppcheck (static code analyzer).
@@ -42,15 +40,16 @@
*/
public class CxxCppCheckSensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxCppCheckSensor.class);
- public static final String REPORT_PATH_KEY = "sonar.cxx.cppcheck.reportPath";
+ public static final String REPORT_PATH_KEY = "cppcheck.reportPath";
+ public static String KEY = "CppCheck";
private final List parsers = new LinkedList<>();
/**
* {@inheritDoc}
*/
- public CxxCppCheckSensor(Settings settings) {
- super(settings, CxxMetrics.CPPCHECK);
+ public CxxCppCheckSensor(CxxLanguage language) {
+ super(language);
parsers.add(new CppcheckParserV2(this));
parsers.add(new CppcheckParserV1(this));
}
@@ -62,7 +61,7 @@ protected String reportPathKey() {
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxCppCheckSensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxCppCheckSensor");
}
@Override
@@ -85,4 +84,9 @@ protected void processReport(final SensorContext context, File report)
LOG.error("Report {} cannot be parsed", report);
}
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/package-info.java
index df35a40149..9edf31190c 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cppcheck/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/cppcheck/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate Cppcheck specific report files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.cppcheck;
+package org.sonar.cxx.sensors.cppcheck;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/CxxDrMemoryRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/CxxDrMemoryRuleRepository.java
similarity index 74%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/CxxDrMemoryRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/CxxDrMemoryRuleRepository.java
index a9e482cd28..3a4c819b91 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/CxxDrMemoryRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/CxxDrMemoryRuleRepository.java
@@ -17,27 +17,27 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.drmemory;
+package org.sonar.cxx.sensors.drmemory;
-import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
-import org.sonar.plugins.cxx.utils.CxxAbstractRuleRepository;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxAbstractRuleRepository;
/**
* {@inheritDoc}
*/
-public final class CxxDrMemoryRuleRepository extends CxxAbstractRuleRepository {
+public class CxxDrMemoryRuleRepository extends CxxAbstractRuleRepository {
public static final String KEY = "drmemory";
- public static final String CUSTOM_RULES_KEY = "sonar.cxx.drmemory.customRules";
+ public static final String CUSTOM_RULES_KEY = "drmemory.customRules";
private static final String NAME = "Dr Memory";
/**
* {@inheritDoc}
*/
- public CxxDrMemoryRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
- super(fileSystem, xmlRuleLoader, settings, KEY, NAME, CUSTOM_RULES_KEY);
+ public CxxDrMemoryRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
+ super(fileSystem, xmlRuleLoader, KEY, NAME, CUSTOM_RULES_KEY, language);
}
@Override
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/CxxDrMemorySensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/CxxDrMemorySensor.java
similarity index 83%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/CxxDrMemorySensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/CxxDrMemorySensor.java
index cc228b2503..5350a898e8 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/CxxDrMemorySensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/CxxDrMemorySensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.drmemory;
+package org.sonar.cxx.sensors.drmemory;
import java.io.File;
import java.io.IOException;
@@ -25,15 +25,13 @@
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.drmemory.DrMemoryParser.DrMemoryError;
-import org.sonar.plugins.cxx.drmemory.DrMemoryParser.DrMemoryError.Location;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
-import org.sonar.plugins.cxx.utils.CxxUtils;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.drmemory.DrMemoryParser.DrMemoryError;
+import org.sonar.cxx.sensors.drmemory.DrMemoryParser.DrMemoryError.Location;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
+import org.sonar.cxx.sensors.utils.CxxUtils;
/**
* Dr. Memory is a memory monitoring tool capable of identifying memory-related
@@ -47,18 +45,19 @@
*/
public class CxxDrMemorySensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxDrMemorySensor.class);
- public static final String REPORT_PATH_KEY = "sonar.cxx.drmemory.reportPath";
+ public static final String REPORT_PATH_KEY = "drmemory.reportPath";
+ public static String KEY = "DrMemory";
/**
* {@inheritDoc}
*/
- public CxxDrMemorySensor(Settings settings) {
- super(settings, CxxMetrics.DRMEMORY);
+ public CxxDrMemorySensor(CxxLanguage language) {
+ super(language);
}
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxDrMemorySensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxDrMemorySensor");
}
@Override
@@ -93,7 +92,7 @@ protected void processReport(final SensorContext context, File report) {
.append("'")
.toString();
LOG.error(msg);
- CxxUtils.validateRecovery(e, settings);
+ CxxUtils.validateRecovery(e, this.language);
}
}
@@ -103,4 +102,9 @@ private boolean isFileInAnalysis(SensorContext context, Location errorLocation)
InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates().is(new File(normalPath)));
return inputFile != null;
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/DrMemoryParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/DrMemoryParser.java
similarity index 97%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/DrMemoryParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/DrMemoryParser.java
index 2e9978bf12..d821867c9d 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/DrMemoryParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/DrMemoryParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.drmemory;
+package org.sonar.cxx.sensors.drmemory;
import java.io.BufferedReader;
import java.io.File;
@@ -28,7 +28,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.sonar.plugins.cxx.drmemory.DrMemoryParser.DrMemoryError.Location;
+import org.sonar.cxx.sensors.drmemory.DrMemoryParser.DrMemoryError.Location;
public class DrMemoryParser {
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/package-info.java
index c590a141a1..0e0cf11c7d 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/drmemory/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/drmemory/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate Dr Memrory specific results files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.drmemory;
+package org.sonar.cxx.sensors.drmemory;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/externalrules/CxxExternalRuleRepository.java
similarity index 81%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/externalrules/CxxExternalRuleRepository.java
index 4592f2f1da..ad8e772239 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/externalrules/CxxExternalRuleRepository.java
@@ -17,16 +17,15 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.externalrules;
+package org.sonar.cxx.sensors.externalrules;
import java.io.StringReader;
-import org.sonar.api.config.Settings;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
+import org.sonar.cxx.CxxLanguage;
/**
* Loads the external rules configuration file.
@@ -34,22 +33,22 @@
public class CxxExternalRuleRepository implements RulesDefinition {
public static final Logger LOG = Loggers.get(CxxExternalRuleRepository.class);
public static final String KEY = "other";
- public static final String RULES_KEY = "sonar.cxx.other.rules";
- public final Settings settings;
+ public static final String RULES_KEY = "other.rules";
private final RulesDefinitionXmlLoader xmlRuleLoader;
private static final String NAME = "Other";
+ private final CxxLanguage language;
- public CxxExternalRuleRepository(RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
+ public CxxExternalRuleRepository(RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
this.xmlRuleLoader = xmlRuleLoader;
- this.settings = settings;
+ this.language = language;
}
@Override
public void define(Context context) {
- NewRepository repository = context.createRepository(KEY, CxxLanguage.KEY).setName(NAME);
+ NewRepository repository = context.createRepository(KEY, this.language.getKey()).setName(NAME);
xmlRuleLoader.load(repository, getClass().getResourceAsStream("/external-rule.xml"), "UTF-8");
- for (String ruleDefs : settings.getStringArray(RULES_KEY)) {
+ for (String ruleDefs : this.language.getStringArrayOption(RULES_KEY)) {
if (ruleDefs != null && !ruleDefs.trim().isEmpty()) {
try {
xmlRuleLoader.load(repository, new StringReader(ruleDefs));
@@ -61,5 +60,4 @@ public void define(Context context) {
repository.done();
}
-
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRulesSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/externalrules/CxxExternalRulesSensor.java
similarity index 83%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRulesSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/externalrules/CxxExternalRulesSensor.java
index 5bc5a09391..d390f1432b 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/CxxExternalRulesSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/externalrules/CxxExternalRulesSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.externalrules;
+package org.sonar.cxx.sensors.externalrules;
import java.io.File;
import javax.xml.stream.XMLStreamException;
@@ -26,13 +26,11 @@
import org.codehaus.staxmate.in.SMInputCursor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
+import org.sonar.cxx.sensors.utils.StaxParser;
/**
* Custom Rule Import, all static analysis are supported.
@@ -41,13 +39,14 @@
*/
public class CxxExternalRulesSensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxExternalRulesSensor.class);
- public static final String REPORT_PATH_KEY = "sonar.cxx.other.reportPath";
+ public static final String REPORT_PATH_KEY = "other.reportPath";
+ public static String KEY = "Other";
/**
* {@inheritDoc}
*/
- public CxxExternalRulesSensor(Settings settings) {
- super(settings, CxxMetrics.EXTERNAL);
+ public CxxExternalRulesSensor(CxxLanguage language) {
+ super(language);
}
@Override
@@ -57,7 +56,7 @@ protected String reportPathKey() {
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxExternalRulesSensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxExternalRulesSensor");
}
@Override
@@ -87,4 +86,9 @@ public void stream(SMHierarchicCursor rootCursor) throws XMLStreamException {
parser.parse(report);
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/externalrules/package-info.java
similarity index 95%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/externalrules/package-info.java
index 35a41b22c8..ec2de9358e 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/externalrules/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/externalrules/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate XML report files (other).
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.externalrules;
+package org.sonar.cxx.sensors.externalrules;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/pclint/CxxPCLintRuleRepository.java
similarity index 74%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/pclint/CxxPCLintRuleRepository.java
index ebe74640ef..9aff74d430 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/pclint/CxxPCLintRuleRepository.java
@@ -17,27 +17,27 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.pclint;
+package org.sonar.cxx.sensors.pclint;
-import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
-import org.sonar.plugins.cxx.utils.CxxAbstractRuleRepository;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxAbstractRuleRepository;
/**
* {@inheritDoc}
*/
-public final class CxxPCLintRuleRepository extends CxxAbstractRuleRepository {
+public class CxxPCLintRuleRepository extends CxxAbstractRuleRepository {
public static final String KEY = "pclint";
- public static final String CUSTOM_RULES_KEY = "sonar.cxx.pclint.customRules";
+ public static final String CUSTOM_RULES_KEY = "pclint.customRules";
private static final String NAME = "PC-lint";
/**
* {@inheritDoc}
*/
- public CxxPCLintRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
- super(fileSystem, xmlRuleLoader, settings, KEY, NAME, CUSTOM_RULES_KEY);
+ public CxxPCLintRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
+ super(fileSystem, xmlRuleLoader, KEY, NAME, CUSTOM_RULES_KEY, language);
}
@Override
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/pclint/CxxPCLintSensor.java
similarity index 89%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/pclint/CxxPCLintSensor.java
index e94d36da64..ed8dea3744 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/CxxPCLintSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/pclint/CxxPCLintSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.pclint;
+package org.sonar.cxx.sensors.pclint;
import java.io.File;
import java.util.regex.Matcher;
@@ -29,15 +29,13 @@
import org.codehaus.staxmate.in.SMInputCursor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
-import org.sonar.plugins.cxx.utils.CxxUtils;
-import org.sonar.plugins.cxx.utils.EmptyReportException;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
+import org.sonar.cxx.sensors.utils.CxxUtils;
+import org.sonar.cxx.sensors.utils.EmptyReportException;
+import org.sonar.cxx.sensors.utils.StaxParser;
/**
* PC-lint is an equivalent to pmd but for C++ The first version of the tool was
@@ -49,13 +47,14 @@
*/
public class CxxPCLintSensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxPCLintSensor.class);
- public static final String REPORT_PATH_KEY = "sonar.cxx.pclint.reportPath";
+ public static final String REPORT_PATH_KEY = "pclint.reportPath";
+ public static String KEY = "PC-Lint";
/**
* {@inheritDoc}
*/
- public CxxPCLintSensor(Settings settings) {
- super(settings, CxxMetrics.PCLINT);
+ public CxxPCLintSensor(CxxLanguage language) {
+ super(language);
}
@Override
@@ -65,7 +64,7 @@ protected String reportPathKey() {
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxPCLintSensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxPCLintSensor");
}
@Override
@@ -148,4 +147,9 @@ private String mapMisraRulesToUniqueSonarRules(String msg) {
parser.parse(report);
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/pclint/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/pclint/package-info.java
index ad2a73c8a9..7285fcddd1 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/pclint/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/pclint/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate PC-Lint specific report files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.pclint;
+package org.sonar.cxx.sensors.pclint;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/rats/CxxRatsRuleRepository.java
similarity index 79%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/rats/CxxRatsRuleRepository.java
index 44bbe2321c..337cfd5148 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/rats/CxxRatsRuleRepository.java
@@ -17,12 +17,12 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.rats;
+package org.sonar.cxx.sensors.rats;
-import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
-import org.sonar.plugins.cxx.utils.CxxAbstractRuleRepository;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxAbstractRuleRepository;
/**
* {@inheritDoc}
@@ -30,14 +30,14 @@
public class CxxRatsRuleRepository extends CxxAbstractRuleRepository {
public static final String KEY = "rats";
- public static final String CUSTOM_RULES_KEY = "sonar.cxx.rats.customRules";
+ public static final String CUSTOM_RULES_KEY = "rats.customRules";
private static final String NAME = "RATS";
/**
* {@inheritDoc}
*/
- public CxxRatsRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
- super(fileSystem, xmlRuleLoader, settings, KEY, NAME, CUSTOM_RULES_KEY);
+ public CxxRatsRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
+ super(fileSystem, xmlRuleLoader, KEY, NAME, CUSTOM_RULES_KEY, language);
}
@Override
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/rats/CxxRatsSensor.java
similarity index 84%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/rats/CxxRatsSensor.java
index 56e8f75e94..8591eb795c 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/CxxRatsSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/rats/CxxRatsSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.rats;
+package org.sonar.cxx.sensors.rats;
import java.io.File;
import java.util.List;
@@ -26,32 +26,31 @@
import org.jdom.input.SAXBuilder;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
-import org.sonar.plugins.cxx.utils.CxxUtils;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
+import org.sonar.cxx.sensors.utils.CxxUtils;
/**
* {@inheritDoc}
*/
-public final class CxxRatsSensor extends CxxReportSensor {
+public class CxxRatsSensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxRatsSensor.class);
private static final String MISSING_RATS_TYPE = "fixed size global buffer";
- public static final String REPORT_PATH_KEY = "sonar.cxx.rats.reportPath";
+ public static final String REPORT_PATH_KEY = "rats.reportPath";
+ public static String KEY = "Rats";
/**
* {@inheritDoc}
*/
- public CxxRatsSensor(Settings settings) {
- super(settings, CxxMetrics.RATS);
+ public CxxRatsSensor(CxxLanguage language) {
+ super(language);
}
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxRatsSensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxRatsSensor");
}
@Override
@@ -100,4 +99,9 @@ private String getVulnerabilityType(Element child) {
}
return MISSING_RATS_TYPE;
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/rats/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/rats/package-info.java
index 077554837d..95be6b5a9c 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/rats/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/rats/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate RATS specific report files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.rats;
+package org.sonar.cxx.sensors.rats;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/api/CustomCxxRulesDefinition.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CustomCxxRulesDefinition.java
similarity index 84%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/api/CustomCxxRulesDefinition.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CustomCxxRulesDefinition.java
index 820d0b0fa7..58741a1ad6 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/api/CustomCxxRulesDefinition.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CustomCxxRulesDefinition.java
@@ -17,14 +17,14 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.api;
+package org.sonar.cxx.sensors.squid;
import org.sonar.api.server.rule.RulesDefinition;
-import org.sonar.plugins.cxx.CxxLanguage;
import org.sonar.squidbridge.annotations.AnnotationBasedRulesDefinition;
import java.util.Arrays;
import org.sonar.api.batch.BatchSide;
+import org.sonar.cxx.CxxLanguage;
/**
*
@@ -35,16 +35,22 @@ public abstract class CustomCxxRulesDefinition implements RulesDefinition {
@Override
public void define(RulesDefinition.Context context) {
- RulesDefinition.NewRepository repo = context.createRepository(repositoryKey(), CxxLanguage.KEY)
+ RulesDefinition.NewRepository repo = context.createRepository(repositoryKey(), getLanguage().getKey())
.setName(repositoryName());
// Load metadata from check classes' annotations
- new AnnotationBasedRulesDefinition(repo, CxxLanguage.KEY).addRuleClasses(false,
+ new AnnotationBasedRulesDefinition(repo, getLanguage().getKey()).addRuleClasses(false,
Arrays.asList(checkClasses()));
repo.done();
}
+ /**
+ * Name of the custom rule repository.
+ * @return
+ */
+ public abstract CxxLanguage getLanguage();
+
/**
* Name of the custom rule repository.
* @return
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/CxxChecks.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxChecks.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/CxxChecks.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxChecks.java
index 630a0c6339..298b388866 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/CxxChecks.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxChecks.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.squid;
+package org.sonar.cxx.sensors.squid;
import java.util.ArrayList;
import java.util.HashSet;
@@ -30,7 +30,6 @@
import org.sonar.api.batch.rule.CheckFactory;
import org.sonar.api.batch.rule.Checks;
import org.sonar.api.rule.RuleKey;
-import org.sonar.plugins.cxx.api.CustomCxxRulesDefinition;
import org.sonar.squidbridge.SquidAstVisitor;
import com.google.common.annotations.VisibleForTesting;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/CxxSquidSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxSquidSensor.java
similarity index 67%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/CxxSquidSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxSquidSensor.java
index f6e9549c4d..b775757233 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/CxxSquidSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/CxxSquidSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.squid;
+package org.sonar.cxx.sensors.squid;
import java.io.File;
import java.io.IOException;
@@ -28,7 +28,6 @@
import java.util.Locale;
import javax.annotation.Nullable;
-import javax.xml.stream.XMLStreamException;
import org.sonar.api.batch.sensor.Sensor;
import org.sonar.api.batch.sensor.SensorContext;
@@ -41,13 +40,7 @@
import org.sonar.cxx.CxxAstScanner;
import org.sonar.cxx.CxxConfiguration;
import org.sonar.cxx.api.CxxMetric;
-import org.sonar.plugins.cxx.api.CustomCxxRulesDefinition;
import org.sonar.cxx.checks.CheckList;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.CxxPlugin;
-import org.sonar.plugins.cxx.compiler.CxxCompilerSensor;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
import org.sonar.squidbridge.AstScanner;
import org.sonar.squidbridge.SquidAstVisitor;
import org.sonar.squidbridge.api.CheckMessage;
@@ -61,6 +54,7 @@
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.sonar.sslr.api.Grammar;
+import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -69,54 +63,89 @@
import org.sonar.api.batch.sensor.issue.NewIssueLocation;
import org.sonar.api.ce.measure.RangeDistributionBuilder;
import org.sonar.api.measures.FileLinesContextFactory;
+import org.sonar.api.measures.Metric;
+import org.sonar.api.measures.Metrics;
import org.sonar.api.rule.RuleKey;
+import org.sonar.cxx.CxxLanguage;
import org.sonar.cxx.parser.CxxParser;
-import org.sonar.plugins.cxx.CxxPlugin.CxxCoverageAggregator;
-import org.sonar.plugins.cxx.coverage.CxxCoverageSensor;
-import org.sonar.plugins.cxx.cpd.CxxCpdVisitor;
-import org.sonar.plugins.cxx.highlighter.CxxHighlighter;
-import org.sonar.plugins.cxx.metrics.FileLinesVisitor;
-
+import org.sonar.cxx.sensors.compiler.CxxCompilerSensor;
+import org.sonar.cxx.sensors.coverage.CxxCoverageCache;
+import org.sonar.cxx.sensors.coverage.CxxCoverageSensor;
+import org.sonar.cxx.sensors.utils.CxxMetrics;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
+import org.sonar.cxx.sensors.utils.JsonCompilationDatabase;
+import org.sonar.cxx.sensors.visitors.CxxCpdVisitor;
+import org.sonar.cxx.sensors.visitors.CxxHighlighterVisitor;
+import org.sonar.cxx.sensors.visitors.FileLinesVisitor;
/**
* {@inheritDoc}
*/
-public final class CxxSquidSensor implements Sensor {
+public class CxxSquidSensor implements Sensor {
+ public static final String SOURCE_FILE_SUFFIXES_KEY = "suffixes.sources";
+ public static final String HEADER_FILE_SUFFIXES_KEY = "suffixes.headers";
+ public static final String DEFINES_KEY = "defines";
+ public static final String INCLUDE_DIRECTORIES_KEY = "includeDirectories";
+ public static final String ERROR_RECOVERY_KEY = "errorRecoveryEnabled";
+ public static final String FORCE_INCLUDE_FILES_KEY = "forceIncludes";
+ public static final String C_FILES_PATTERNS_KEY = "cFilesPatterns";
+ public static final String MISSING_INCLUDE_WARN = "missingIncludeWarnings";
+ public static final String JSON_COMPILATION_DATABASE_KEY = "jsonCompilationDatabase";
+ public static final String SCAN_ONLY_SPECIFIED_SOURCES_KEY = "scanOnlySpecifiedSources";
+
+ public static final String CPD_IGNORE_LITERALS_KEY = "cpd.ignoreLiterals";
+ public static final String CPD_IGNORE_IDENTIFIERS_KEY = "cpd.ignoreIdentifiers";
+
private static final Number[] LIMITS_COMPLEXITY_METHODS = {1, 2, 4, 6, 8, 10, 12, 20, 30};
private static final Number[] LIMITS_COMPLEXITY_FILES = {0, 5, 10, 20, 30, 60, 90};
+ public static String KEY = "Squid";
private final FileLinesContextFactory fileLinesContextFactory;
private final CxxChecks checks;
private ActiveRules rules;
private AstScanner scanner;
- private Settings settings;
-
-
+ private final CxxLanguage language;
+ private final CxxCoverageCache cache;
+
/**
* {@inheritDoc}
*/
- public CxxSquidSensor(Settings settings, FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory, ActiveRules rules) {
- this(settings, fileLinesContextFactory, checkFactory, rules, null);
+ public CxxSquidSensor(CxxLanguage language,
+ FileLinesContextFactory fileLinesContextFactory,
+ CheckFactory checkFactory,
+ ActiveRules rules,
+ @Nullable CxxCoverageCache coverageCache) {
+ this(language, fileLinesContextFactory, checkFactory, rules, null, coverageCache);
}
/**
* {@inheritDoc}
*/
- public CxxSquidSensor(Settings settings, FileLinesContextFactory fileLinesContextFactory, CheckFactory checkFactory, ActiveRules rules,
- @Nullable CustomCxxRulesDefinition[] customRulesDefinition) {
+ public CxxSquidSensor(CxxLanguage language,
+ FileLinesContextFactory fileLinesContextFactory,
+ CheckFactory checkFactory,
+ ActiveRules rules,
+ @Nullable CustomCxxRulesDefinition[] customRulesDefinition,
+ @Nullable CxxCoverageCache coverageCache) {
this.checks = CxxChecks.createCxxCheck(checkFactory)
.addChecks(CheckList.REPOSITORY_KEY, CheckList.getChecks())
.addCustomChecks(customRulesDefinition);
this.fileLinesContextFactory = fileLinesContextFactory;
this.rules = rules;
- this.settings = settings;
+ this.language = language;
+
+ if (coverageCache == null) {
+ this.cache = new CxxCoverageCache();
+ } else {
+ this.cache = coverageCache;
+ }
}
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxSquidSensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxSquidSensor");
}
/**
@@ -127,12 +156,16 @@ public void execute(SensorContext context) {
Map> linesOfCode = new HashMap<>();
List> visitors = new ArrayList<>((Collection) checks.all());
- visitors.add(new CxxHighlighter(context));
+ visitors.add(new CxxHighlighterVisitor(context));
visitors.add(new FileLinesVisitor(fileLinesContextFactory, context.fileSystem(), linesOfCode));
- visitors.add(new CxxCpdVisitor(context, settings.getBoolean(CxxPlugin.CPD_IGNORE_LITERALS_KEY), settings.getBoolean(CxxPlugin.CPD_IGNORE_IDENTIFIERS_KEY)));
+ visitors.add(
+ new CxxCpdVisitor(
+ context,
+ this.language.getBooleanOption(CPD_IGNORE_LITERALS_KEY),
+ this.language.getBooleanOption(CPD_IGNORE_IDENTIFIERS_KEY)));
- CxxConfiguration cxxConf = createConfiguration(context.fileSystem(), settings);
- this.scanner = CxxAstScanner.create(cxxConf, context,
+ CxxConfiguration cxxConf = createConfiguration(context.fileSystem());
+ this.scanner = CxxAstScanner.create(this.language, cxxConf, context,
visitors.toArray(new SquidAstVisitor[visitors.size()]));
List files;
@@ -141,7 +174,7 @@ public void execute(SensorContext context) {
} else {
Iterable inputFiles = context.fileSystem().inputFiles(context.fileSystem().predicates()
.and(context.fileSystem().predicates()
- .hasLanguage(CxxLanguage.KEY), context.fileSystem().predicates()
+ .hasLanguage(this.language.getKey()), context.fileSystem().predicates()
.hasType(InputFile.Type.MAIN)));
files = new ArrayList<>();
@@ -151,31 +184,29 @@ public void execute(SensorContext context) {
}
scanner.scanFiles(files);
- (new CxxCoverageSensor(settings, new CxxCoverageAggregator())).execute(context, linesOfCode);
+ (new CxxCoverageSensor(this.cache, this.language)).execute(context, linesOfCode);
Collection squidSourceFiles = scanner.getIndex().search(new QueryByType(SourceFile.class));
save(squidSourceFiles, context);
}
- private CxxConfiguration createConfiguration(FileSystem fs, Settings settings) {
- CxxConfiguration cxxConf = new CxxConfiguration(fs);
+ private CxxConfiguration createConfiguration(FileSystem fs) {
+ CxxConfiguration cxxConf = new CxxConfiguration(fs, this.language);
cxxConf.setBaseDir(fs.baseDir().getAbsolutePath());
- String[] lines = settings.getStringLines(CxxPlugin.DEFINES_KEY);
- if (lines.length > 0) {
- cxxConf.setDefines(Arrays.asList(lines));
- }
- cxxConf.setIncludeDirectories(settings.getStringArray(CxxPlugin.INCLUDE_DIRECTORIES_KEY));
- cxxConf.setErrorRecoveryEnabled(settings.getBoolean(CxxPlugin.ERROR_RECOVERY_KEY));
- cxxConf.setForceIncludeFiles(settings.getStringArray(CxxPlugin.FORCE_INCLUDE_FILES_KEY));
- cxxConf.setCFilesPatterns(settings.getStringArray(CxxPlugin.C_FILES_PATTERNS_KEY));
- cxxConf.setHeaderFileSuffixes(settings.getStringArray(CxxPlugin.HEADER_FILE_SUFFIXES_KEY));
- cxxConf.setMissingIncludeWarningsEnabled(settings.getBoolean(CxxPlugin.MISSING_INCLUDE_WARN));
- cxxConf.setJsonCompilationDatabaseFile(settings.getString(CxxPlugin.JSON_COMPILATION_DATABASE_KEY));
- cxxConf.setScanOnlySpecifiedSources(settings.getBoolean(CxxPlugin.SCAN_ONLY_SPECIFIED_SOURCES_KEY));
+ String[] lines = this.language.getStringLinesOption(DEFINES_KEY);
+ cxxConf.setDefines(lines);
+ cxxConf.setIncludeDirectories(this.language.getStringArrayOption(INCLUDE_DIRECTORIES_KEY));
+ cxxConf.setErrorRecoveryEnabled(this.language.getBooleanOption(ERROR_RECOVERY_KEY));
+ cxxConf.setForceIncludeFiles(this.language.getStringArrayOption(FORCE_INCLUDE_FILES_KEY));
+ cxxConf.setCFilesPatterns(this.language.getStringArrayOption(C_FILES_PATTERNS_KEY));
+ cxxConf.setHeaderFileSuffixes(this.language.getStringArrayOption(HEADER_FILE_SUFFIXES_KEY));
+ cxxConf.setMissingIncludeWarningsEnabled(this.language.getBooleanOption(MISSING_INCLUDE_WARN));
+ cxxConf.setJsonCompilationDatabaseFile(this.language.getStringOption(JSON_COMPILATION_DATABASE_KEY));
+ cxxConf.setScanOnlySpecifiedSources(this.language.getBooleanOption(SCAN_ONLY_SPECIFIED_SOURCES_KEY));
if (cxxConf.getJsonCompilationDatabaseFile() != null) {
try {
- new org.sonar.plugins.cxx.utils.JsonCompilationDatabase(cxxConf, new File(cxxConf.getJsonCompilationDatabaseFile()));
+ new JsonCompilationDatabase(cxxConf, new File(cxxConf.getJsonCompilationDatabaseFile()));
} catch (JsonParseException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
@@ -185,12 +216,12 @@ private CxxConfiguration createConfiguration(FileSystem fs, Settings settings) {
}
}
- String filePaths = settings.getString(CxxCompilerSensor.REPORT_PATH_KEY);
+ String filePaths = this.language.getStringOption(CxxCompilerSensor.REPORT_PATH_KEY);
if (filePaths != null && !"".equals(filePaths)) {
- List reports = CxxReportSensor.getReports(settings, fs.baseDir(), CxxCompilerSensor.REPORT_PATH_KEY);
+ List reports = CxxReportSensor.getReports(this.language, fs.baseDir(), CxxCompilerSensor.REPORT_PATH_KEY);
cxxConf.setCompilationPropertiesWithBuildLog(reports,
- settings.getString(CxxCompilerSensor.PARSER_KEY_DEF),
- settings.getString(CxxCompilerSensor.REPORT_CHARSET_DEF));
+ this.language.getStringOption(CxxCompilerSensor.PARSER_KEY_DEF),
+ this.language.getStringOption(CxxCompilerSensor.REPORT_CHARSET_DEF));
}
return cxxConf;
@@ -212,7 +243,17 @@ private void save(Collection squidSourceFiles, SensorContext context
dependencyAnalyzer.addFile(inputFile, CxxParser.getIncludedFiles(ioFile), context);
}
- context.newMeasure().forMetric(CxxMetrics.SQUID).on(context.module()).withValue(violationsCount).save();
+ String metricKey = CxxMetrics.GetKey(KEY, language);
+ Metric metric = this.language.getMetric(metricKey);
+
+ if (metric != null) {
+ context.newMeasure()
+ .forMetric(metric)
+ .on(context.module())
+ .withValue(violationsCount)
+ .save();
+ }
+
dependencyAnalyzer.save(context);
}
@@ -293,4 +334,11 @@ private int saveViolations(InputFile inputFile, SourceFile squidFile, SensorCont
public String toString() {
return getClass().getSimpleName();
}
+
+ //@Override
+ //public List getMetrics() {
+ // List list = new ArrayList<>();
+ // list.add(this.metric);
+ // return list;
+ // }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DependencyAnalyzer.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/DependencyAnalyzer.java
similarity index 99%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DependencyAnalyzer.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/DependencyAnalyzer.java
index d567504bfe..b2d1d05297 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DependencyAnalyzer.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/DependencyAnalyzer.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.squid;
+package org.sonar.cxx.sensors.squid;
import java.util.Collection;
import java.util.HashMap;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DirectoryEdge.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/DirectoryEdge.java
similarity index 97%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DirectoryEdge.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/DirectoryEdge.java
index 8ec4559c03..7c4405c232 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/DirectoryEdge.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/DirectoryEdge.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.squid;
+package org.sonar.cxx.sensors.squid;
import java.util.Collection;
import java.util.HashSet;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/FileEdge.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/FileEdge.java
similarity index 97%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/FileEdge.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/FileEdge.java
index 967b400547..05599ac47b 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/FileEdge.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/FileEdge.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.squid;
+package org.sonar.cxx.sensors.squid;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.graph.Edge;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/package-info.java
index b6bc11b557..fcd8ac9e48 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/squid/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/squid/package-info.java
@@ -22,6 +22,6 @@
* Package with Squid sensor and Squid based functionality.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.squid;
+package org.sonar.cxx.sensors.squid;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/dotnet/CxxUnitTestResultsProvider.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/dotnet/CxxUnitTestResultsProvider.java
similarity index 86%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/dotnet/CxxUnitTestResultsProvider.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/dotnet/CxxUnitTestResultsProvider.java
index b24d14a848..3622531900 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/dotnet/CxxUnitTestResultsProvider.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/dotnet/CxxUnitTestResultsProvider.java
@@ -17,23 +17,24 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.tests.dotnet;
+package org.sonar.cxx.sensors.tests.dotnet;
import org.sonar.api.batch.bootstrap.ProjectDefinition;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.utils.CxxUtils;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxUtils;
import org.sonar.plugins.dotnet.tests.UnitTestConfiguration;
import org.sonar.plugins.dotnet.tests.UnitTestResultsAggregator;
import org.sonar.plugins.dotnet.tests.UnitTestResultsImportSensor;
public class CxxUnitTestResultsProvider {
- public static final String VISUAL_STUDIO_TEST_RESULTS_PROPERTY_KEY = "sonar.cxx.vstest.reportsPaths";
- public static final String NUNIT_TEST_RESULTS_PROPERTY_KEY = "sonar.cxx.nunit.reportsPaths";
- public static final String XUNIT_TEST_RESULTS_PROPERTY_KEY = "sonar.cxx.xunit.reportsPaths";
+ public static final String VISUAL_STUDIO_TEST_RESULTS_PROPERTY_KEY = "vstest.reportsPaths";
+ public static final String NUNIT_TEST_RESULTS_PROPERTY_KEY = "nunit.reportsPaths";
+ public static final String XUNIT_TEST_RESULTS_PROPERTY_KEY = "xunit.reportsPaths";
private static final UnitTestConfiguration UNIT_TEST_CONF = new UnitTestConfiguration(
VISUAL_STUDIO_TEST_RESULTS_PROPERTY_KEY,
@@ -53,9 +54,11 @@ public CxxUnitTestResultsAggregator(Settings settings) {
public static class CxxUnitTestResultsImportSensor extends UnitTestResultsImportSensor {
public static final Logger LOG = Loggers.get(CxxUnitTestResultsImportSensor.class);
+ private final CxxLanguage language;
- public CxxUnitTestResultsImportSensor(CxxUnitTestResultsAggregator unitTestResultsAggregator, ProjectDefinition projectDef) {
+ public CxxUnitTestResultsImportSensor(CxxUnitTestResultsAggregator unitTestResultsAggregator, ProjectDefinition projectDef, CxxLanguage language) {
super(unitTestResultsAggregator, projectDef);
+ this.language = language;
}
@Override
@@ -69,7 +72,7 @@ public void execute(SensorContext context) {
.append("'")
.toString();
LOG.error(msg);
- CxxUtils.validateRecovery(e, context.settings());
+ CxxUtils.validateRecovery(e, this.language);
}
}
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/dotnet/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/dotnet/package-info.java
similarity index 95%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/dotnet/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/dotnet/package-info.java
index 659d82fa19..4da96420b9 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/dotnet/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/dotnet/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate Unit Test specific report files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.tests.dotnet;
+package org.sonar.cxx.sensors.tests.dotnet;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/CxxXunitSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/CxxXunitSensor.java
similarity index 87%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/CxxXunitSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/CxxXunitSensor.java
index 688ea1fe37..cb37a0fae4 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/CxxXunitSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/CxxXunitSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.tests.xunit;
+package org.sonar.cxx.sensors.tests.xunit;
import java.io.File;
import java.io.IOException;
@@ -38,26 +38,27 @@
import javax.xml.transform.stream.StreamSource;
import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.api.config.Settings;
import org.sonar.api.measures.CoreMetrics;
import org.sonar.api.utils.ParsingUtils;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
-import org.sonar.plugins.cxx.utils.EmptyReportException;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
+import org.sonar.cxx.sensors.utils.EmptyReportException;
import org.sonar.api.batch.sensor.SensorDescriptor;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.utils.CxxUtils;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxUtils;
+import org.sonar.cxx.sensors.utils.StaxParser;
/**
* {@inheritDoc}
*/
public class CxxXunitSensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxXunitSensor.class);
- public static final String REPORT_PATH_KEY = "sonar.cxx.xunit.reportPath";
- public static final String XSLT_URL_KEY = "sonar.cxx.xunit.xsltURL";
+ public static final String REPORT_PATH_KEY = "xunit.reportPath";
+ public static final String KEY = "Xunit";
+ public static final String XSLT_URL_KEY = "xunit.xsltURL";
private static final double PERCENT_BASE = 100d;
-
+
private String xsltURL;
static Pattern classNameOnlyMatchingPattern = Pattern.compile("(?:\\w*::)*?(\\w+?)::\\w+?:\\d+$");
@@ -66,12 +67,11 @@ public class CxxXunitSensor extends CxxReportSensor {
/**
* {@inheritDoc}
*/
- public CxxXunitSensor(Settings settings) {
- super(settings, null);
- xsltURL = settings.getString(XSLT_URL_KEY);
+ public CxxXunitSensor(CxxLanguage language) {
+ super(language);
+ xsltURL = language.getStringOption(XSLT_URL_KEY);
}
- @Override
protected String reportPathKey() {
return REPORT_PATH_KEY;
}
@@ -95,7 +95,7 @@ public void execute(SensorContext context) {
LOG.debug("Root module imports test metrics: Module Key = '{}'", context.module());
try {
- List reports = getReports(settings, context.fileSystem().baseDir(), REPORT_PATH_KEY);
+ List reports = getReports(this.language, context.fileSystem().baseDir(), REPORT_PATH_KEY);
if (!reports.isEmpty()) {
XunitReportParser parserHandler = new XunitReportParser();
StaxParser parser = new StaxParser(parserHandler, false);
@@ -121,7 +121,7 @@ public void execute(SensorContext context) {
.append("'")
.toString();
LOG.error(msg);
- CxxUtils.validateRecovery(e, settings);
+ CxxUtils.validateRecovery(e, this.language);
}
}
@@ -161,7 +161,7 @@ private void simpleMode(final SensorContext context, List testcases)
.save();
} catch(Exception ex) {
LOG.error("Cannot save measure TESTS : '{}', ignoring measure", ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
try
@@ -173,7 +173,7 @@ private void simpleMode(final SensorContext context, List testcases)
.save();
} catch(Exception ex) {
LOG.error("Cannot save measure TEST_ERRORS : '{}', ignoring measure", ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
try
@@ -185,7 +185,7 @@ private void simpleMode(final SensorContext context, List testcases)
.save();
} catch(Exception ex) {
LOG.error("Cannot save measure TEST_FAILURES : '{}', ignoring measure", ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
try
@@ -197,7 +197,7 @@ private void simpleMode(final SensorContext context, List testcases)
.save();
} catch(Exception ex) {
LOG.error("Cannot save measure SKIPPED_TESTS : '{}', ignoring measure", ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
try
@@ -209,7 +209,7 @@ private void simpleMode(final SensorContext context, List testcases)
.save();
} catch(Exception ex) {
LOG.error("Cannot save measure TEST_SUCCESS_DENSITY : '{}', ignoring measure", ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
try
@@ -221,15 +221,13 @@ private void simpleMode(final SensorContext context, List testcases)
.save();
} catch(Exception ex) {
LOG.error("Cannot save measure TEST_EXECUTION_TIME : '{}', ignoring measure", ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
} else {
LOG.debug("The reports contain no testcases");
}
}
-
-
File transformReport(File report)
throws java.io.IOException, javax.xml.transform.TransformerException {
File transformed = report;
@@ -258,4 +256,9 @@ File transformReport(File report)
return transformed;
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/TestCase.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/TestCase.java
similarity index 99%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/TestCase.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/TestCase.java
index 01af1d38bf..a9a144f5fa 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/TestCase.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/TestCase.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.tests.xunit;
+package org.sonar.cxx.sensors.tests.xunit;
import org.apache.commons.lang.StringEscapeUtils;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/TestFile.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/TestFile.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/TestFile.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/TestFile.java
index 39dfde50b7..bad0f7ea34 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/TestFile.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/TestFile.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.tests.xunit;
+package org.sonar.cxx.sensors.tests.xunit;
import java.util.ArrayList;
import java.util.List;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/XunitReportParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/XunitReportParser.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/XunitReportParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/XunitReportParser.java
index 6fb4ee25d9..61c9bd55a5 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/XunitReportParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/XunitReportParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.tests.xunit;
+package org.sonar.cxx.sensors.tests.xunit;
import java.text.ParseException;
import java.util.LinkedList;
@@ -30,8 +30,8 @@
import org.codehaus.staxmate.in.SMHierarchicCursor;
import org.codehaus.staxmate.in.SMInputCursor;
import org.sonar.api.utils.ParsingUtils;
-import org.sonar.plugins.cxx.utils.EmptyReportException;
-import org.sonar.plugins.cxx.utils.StaxParser.XmlStreamHandler;
+import org.sonar.cxx.sensors.utils.EmptyReportException;
+import org.sonar.cxx.sensors.utils.StaxParser.XmlStreamHandler;
/**
* {@inheritDoc}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/package-info.java
index 204f72e587..07d873b61d 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/tests/xunit/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/tests/xunit/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate Unit Test specific report files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.tests.xunit;
+package org.sonar.cxx.sensors.tests.xunit;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxAbstractRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxAbstractRuleRepository.java
similarity index 89%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxAbstractRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxAbstractRuleRepository.java
index 407d0ee0fb..3be628ef61 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxAbstractRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxAbstractRuleRepository.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.utils;
+package org.sonar.cxx.sensors.utils;
import java.io.File;
import java.io.FileReader;
@@ -27,13 +27,12 @@
import java.util.List;
import org.apache.commons.io.FileUtils;
-import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
+import org.sonar.cxx.CxxLanguage;
/**
* {@inheritDoc}
@@ -43,27 +42,27 @@ public abstract class CxxAbstractRuleRepository implements RulesDefinition {
public static final Logger LOG = Loggers.get(CxxAbstractRuleRepository.class);
private final ServerFileSystem fileSystem;
- public final Settings settings;
private final RulesDefinitionXmlLoader xmlRuleLoader;
protected final String repositoryKey;
protected final String repositoryName;
protected final String customRepositoryKey;
+ private final CxxLanguage language;
/**
* {@inheritDoc}
*/
- public CxxAbstractRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings, String key, String name, String customKey) {
+ public CxxAbstractRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, String key, String name, String customKey, CxxLanguage language) {
this.fileSystem = fileSystem;
this.xmlRuleLoader = xmlRuleLoader;
this.repositoryKey = key;
this.repositoryName = name;
this.customRepositoryKey = customKey;
- this.settings = settings;
+ this.language = language;
}
@Override
public void define(Context context) {
- NewRepository repository = context.createRepository(repositoryKey, CxxLanguage.KEY).setName(repositoryName);
+ NewRepository repository = context.createRepository(repositoryKey, this.language.getKey()).setName(repositoryName);
RulesDefinitionXmlLoader xmlLoader = new RulesDefinitionXmlLoader();
if (!"".equals(fileName())) {
@@ -80,7 +79,7 @@ public void define(Context context) {
}
}
- String customRules = settings.getString(this.customRepositoryKey);
+ String customRules = language.getStringOption(this.customRepositoryKey);
if (customRules != null && !customRules.trim().isEmpty()) {
xmlRuleLoader.load(repository, new StringReader(customRules));
}
diff --git a/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxMetrics.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxMetrics.java
new file mode 100644
index 0000000000..f4a316aea1
--- /dev/null
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxMetrics.java
@@ -0,0 +1,77 @@
+/*
+ * Sonar C++ Plugin (Community)
+ * Copyright (C) 2010-2017 SonarOpenCommunity
+ * http://github.com/SonarOpenCommunity/sonar-cxx
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.cxx.sensors.utils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.sonar.api.measures.Metric;
+import org.sonar.api.measures.Metrics;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.compiler.CxxCompilerSensor;
+import org.sonar.cxx.sensors.cppcheck.CxxCppCheckSensor;
+import org.sonar.cxx.sensors.drmemory.CxxDrMemorySensor;
+import org.sonar.cxx.sensors.externalrules.CxxExternalRulesSensor;
+import org.sonar.cxx.sensors.pclint.CxxPCLintSensor;
+import org.sonar.cxx.sensors.rats.CxxRatsSensor;
+import org.sonar.cxx.sensors.squid.CxxSquidSensor;
+import org.sonar.cxx.sensors.valgrind.CxxValgrindSensor;
+import org.sonar.cxx.sensors.veraxx.CxxVeraxxSensor;
+
+/**
+ * {@inheritDoc}
+ */
+public class CxxMetrics implements Metrics {
+ private final CxxLanguage language;
+
+ public static String GetKey(String key, CxxLanguage language) {
+ return language.getPropertiesKey().toUpperCase() + "-" + key.toUpperCase();
+ }
+
+ public CxxMetrics(CxxLanguage language) {
+ this.language = language;
+
+ this.BuildMetric(CxxCompilerSensor.KEY, "Compiler issues", language);
+ this.BuildMetric(CxxCppCheckSensor.KEY, "CppCheck issues", language);
+ this.BuildMetric(CxxExternalRulesSensor.KEY, "Other tools issues", language);
+ this.BuildMetric(CxxPCLintSensor.KEY, "PC-Lint issues", language);
+ this.BuildMetric(CxxRatsSensor.KEY, "Rats issues", language);
+ this.BuildMetric(CxxSquidSensor.KEY, "Squid issues", language);
+ this.BuildMetric(CxxValgrindSensor.KEY, "Valgrind issues", language);
+ this.BuildMetric(CxxVeraxxSensor.KEY, "Vera issues", language);
+ this.BuildMetric(CxxDrMemorySensor.KEY, "DrMemory issues", language);
+ }
+
+ @Override
+ public List getMetrics() {
+ return new ArrayList(this.language.getMetricsCache());
+ }
+
+ private void BuildMetric(String key, String description, CxxLanguage language) {
+ String effectiveKey = CxxMetrics.GetKey(key, language);
+ Metric metric = new Metric.Builder(effectiveKey, description, Metric.ValueType.INT)
+ .setDirection(Metric.DIRECTION_WORST)
+ .setQualitative(Boolean.TRUE)
+ .setDomain(language.getKey().toUpperCase())
+ .create();
+
+ language.SaveMetric(metric, key);
+ }
+}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxReportSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxReportSensor.java
similarity index 83%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxReportSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxReportSensor.java
index 01ba45ae3f..695d41e7c6 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxReportSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxReportSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.utils;
+package org.sonar.cxx.sensors.utils;
import java.io.File;
import java.util.Arrays;
@@ -34,9 +34,9 @@
import org.sonar.api.rule.RuleKey;
import org.sonar.api.batch.sensor.issue.NewIssue;
import org.sonar.api.batch.sensor.issue.NewIssueLocation;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
+import org.sonar.cxx.CxxLanguage;
/**
* This class is used as base for all sensors which import reports. It hosts
@@ -46,11 +46,9 @@ public abstract class CxxReportSensor implements Sensor {
public static final Logger LOG = Loggers.get(CxxReportSensor.class);
private final Set notFoundFiles = new HashSet<>();
private final Set uniqueIssues = new HashSet<>();
- private final Metric metric;
private int violationsCount;
-
- protected Settings settings;
-
+ protected final CxxLanguage language;
+
/**
* Use this constructor if your sensor implementation saves violations aka
* issues
@@ -61,9 +59,8 @@ public abstract class CxxReportSensor implements Sensor {
* @param metric this metrics will be used to save a measure of the overall
* issue count. Pass 'null' to skip this.
*/
- protected CxxReportSensor(Settings settings, Metric metric) {
- this.settings = settings;
- this.metric = metric;
+ protected CxxReportSensor(CxxLanguage language) {
+ this.language = language;
}
/**
@@ -73,7 +70,7 @@ protected CxxReportSensor(Settings settings, Metric metric) {
public void execute(SensorContext context) {
try {
LOG.info("Searching reports by relative path with basedir '{}' and search prop '{}'", context.fileSystem().baseDir(), reportPathKey());
- List reports = getReports(settings, context.fileSystem().baseDir(), reportPathKey());
+ List reports = getReports(language, context.fileSystem().baseDir(), reportPathKey());
violationsCount = 0;
for (File report : reports) {
@@ -81,23 +78,24 @@ public void execute(SensorContext context) {
LOG.info("Processing report '{}'", report);
try {
processReport(context, report);
- LOG.debug("{} processed = {}", metric == null ? "Issues" : metric.getName(),
- violationsCount - prevViolationsCount);
+ LOG.debug("{} processed = {}", CxxMetrics.GetKey(this.getSensorKey(), language), violationsCount - prevViolationsCount);
} catch (EmptyReportException e) {
LOG.warn("The report '{}' seems to be empty, ignoring.", report);
- CxxUtils.validateRecovery(e, settings);
+ CxxUtils.validateRecovery(e, language);
}
}
- LOG.info("{} processed = {}", metric == null ? "Issues" : metric.getName(),
- violationsCount);
+ LOG.info("{} processed = {}", CxxMetrics.GetKey(this.getSensorKey(), language), violationsCount);
+ String metricKey = CxxMetrics.GetKey(this.getSensorKey(), language);
+ Metric metric = this.language.getMetric(metricKey);
+
if (metric != null) {
context.newMeasure()
- .forMetric(metric)
- .on(context.module())
- .withValue(violationsCount)
- .save();
+ .forMetric(metric)
+ .on(context.module())
+ .withValue(violationsCount)
+ .save();
}
} catch (Exception e) {
String msg = new StringBuilder()
@@ -106,7 +104,7 @@ public void execute(SensorContext context) {
.append("'")
.toString();
LOG.error(msg);
- CxxUtils.validateRecovery(e, settings);
+ CxxUtils.validateRecovery(e, this.language);
}
}
@@ -116,19 +114,24 @@ public String toString() {
}
protected String getStringProperty(String name, String def) {
- String value = settings.getString(name);
+ String value = this.language.getStringOption(name);
if (value == null) {
value = def;
}
return value;
}
- public static List getReports(Settings settings, final File moduleBaseDir,
- String reportPathPropertyKey) {
+ public static List getReports(CxxLanguage language,
+ final File moduleBaseDir,
+ String genericReportKeyData) {
List reports = new ArrayList<>();
-
- List reportPaths = Arrays.asList(settings.getStringArray(reportPathPropertyKey));
+
+ if ("".equals(genericReportKeyData) || genericReportKeyData == null) {
+ return reports;
+ }
+
+ List reportPaths = Arrays.asList(language.getStringArrayOption(genericReportKeyData));
if (!reportPaths.isEmpty()) {
List includes = new ArrayList<>();
for (String reportPath : reportPaths) {
@@ -163,12 +166,12 @@ public static List getReports(Settings settings, final File moduleBaseDir,
}
if (reports.isEmpty()) {
- LOG.warn("Cannot find a report for '{}'", reportPathPropertyKey);
+ LOG.warn("Cannot find a report for '{}'", genericReportKeyData);
} else {
LOG.info("Parser will parse '{}' report files", reports.size());
}
} else {
- LOG.info("Undefined report path value for key '{}'", reportPathPropertyKey);
+ LOG.info("Undefined report path value for key '{}'", genericReportKeyData);
}
return reports;
@@ -222,7 +225,7 @@ private void saveViolation(SensorContext sensorContext, String ruleRepoKey, Stri
violationsCount++;
} catch (Exception ex) {
LOG.error("Could not add the issue '{}', skipping issue", ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
} else {
LOG.warn("Cannot find the file '{}', skipping violations", normalPath);
@@ -241,7 +244,7 @@ private void saveViolation(SensorContext sensorContext, String ruleRepoKey, Stri
violationsCount++;
} catch (Exception ex) {
LOG.error("Could not add the issue '{}', skipping issue", ex.getMessage());
- CxxUtils.validateRecovery(ex, settings);
+ CxxUtils.validateRecovery(ex, this.language);
}
}
}
@@ -258,7 +261,7 @@ private int getLineAsInt(String line, int maxLine) {
}
} catch (java.lang.NumberFormatException nfe) {
LOG.warn("Skipping invalid line number: {}", line);
- CxxUtils.validateRecovery(nfe, settings);
+ CxxUtils.validateRecovery(nfe, this.language);
lineNr = -1;
}
}
@@ -269,7 +272,6 @@ protected void processReport(final SensorContext context, File report)
throws Exception {
}
- protected String reportPathKey() {
- return "";
- }
+ abstract protected String reportPathKey();
+ abstract protected String getSensorKey();
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxUtils.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxUtils.java
similarity index 90%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxUtils.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxUtils.java
index 31056efad9..b6c990eb4d 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxUtils.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/CxxUtils.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.utils;
+package org.sonar.cxx.sensors.utils;
import java.io.File;
import java.io.PrintWriter;
@@ -25,7 +25,7 @@
import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxPlugin;
+import org.sonar.cxx.CxxLanguage;
/**
@@ -33,6 +33,8 @@
*/
public final class CxxUtils {
+ public static final String ERROR_RECOVERY_KEY = "errorRecoveryEnabled";
+
/**
* Default logger.
*/
@@ -85,8 +87,8 @@ public static String getStackTrace(final Throwable throwable) {
return sw.getBuffer().toString();
}
- public static void validateRecovery(Exception ex, Settings settings) throws IllegalStateException {
- if (!settings.getBoolean(CxxPlugin.ERROR_RECOVERY_KEY)) {
+ public static void validateRecovery(Exception ex, CxxLanguage language) throws IllegalStateException {
+ if (!language.IsRecoveryEnabled()) {
LOG.info("Recovery is disabled, failing analysis : '{}'", ex.toString());
throw new IllegalStateException(ex.getMessage(), ex.getCause());
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/EmptyReportException.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/EmptyReportException.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/EmptyReportException.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/EmptyReportException.java
index a87cc5eccf..d2218345be 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/EmptyReportException.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/EmptyReportException.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.utils;
+package org.sonar.cxx.sensors.utils;
@SuppressWarnings("serial")
/**
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/JsonCompilationDatabase.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/JsonCompilationDatabase.java
similarity index 99%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/JsonCompilationDatabase.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/JsonCompilationDatabase.java
index 5248a55118..b7bf5936e2 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/JsonCompilationDatabase.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/JsonCompilationDatabase.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.utils;
+package org.sonar.cxx.sensors.utils;
import java.io.File;
import java.io.IOException;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/JsonCompilationDatabaseCommandObject.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/JsonCompilationDatabaseCommandObject.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/JsonCompilationDatabaseCommandObject.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/JsonCompilationDatabaseCommandObject.java
index 6e4099bca2..66fe00a6d9 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/JsonCompilationDatabaseCommandObject.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/JsonCompilationDatabaseCommandObject.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.utils;
+package org.sonar.cxx.sensors.utils;
import java.io.Serializable;
import java.util.HashMap;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/StaxParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/StaxParser.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/StaxParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/StaxParser.java
index fff6340ab2..aecfc0f8f5 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/StaxParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/StaxParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.utils;
+package org.sonar.cxx.sensors.utils;
import com.ctc.wstx.stax.WstxInputFactory;
import java.io.File;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/package-info.java
index f7ea09935a..a7f08374c5 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/utils/package-info.java
@@ -22,6 +22,6 @@
* Package with helpers and base classes for sensors and plug-in.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.utils;
+package org.sonar.cxx.sensors.utils;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/CxxValgrindRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindRuleRepository.java
similarity index 79%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/CxxValgrindRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindRuleRepository.java
index f2dee8657e..73013e5fa7 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/CxxValgrindRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindRuleRepository.java
@@ -17,12 +17,12 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.valgrind;
+package org.sonar.cxx.sensors.valgrind;
-import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
-import org.sonar.plugins.cxx.utils.CxxAbstractRuleRepository;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxAbstractRuleRepository;
/**
* {@inheritDoc}
@@ -30,14 +30,14 @@
public class CxxValgrindRuleRepository extends CxxAbstractRuleRepository {
static final String KEY = "valgrind";
- public static final String CUSTOM_RULES_KEY = "sonar.cxx.valgrind.customRules";
+ public static final String CUSTOM_RULES_KEY = "valgrind.customRules";
private static final String NAME = "Valgrind";
/**
* {@inheritDoc}
*/
- public CxxValgrindRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
- super(fileSystem, xmlRuleLoader, settings, KEY, NAME, CUSTOM_RULES_KEY);
+ public CxxValgrindRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
+ super(fileSystem, xmlRuleLoader, KEY, NAME, CUSTOM_RULES_KEY, language);
}
@Override
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/CxxValgrindSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensor.java
similarity index 83%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/CxxValgrindSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensor.java
index 0803688ade..9b765250f5 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/CxxValgrindSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/CxxValgrindSensor.java
@@ -17,35 +17,33 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.valgrind;
+package org.sonar.cxx.sensors.valgrind;
import java.io.File;
import java.util.Set;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
/**
* {@inheritDoc}
*/
public class CxxValgrindSensor extends CxxReportSensor {
public static final Logger LOG = Loggers.get(CxxValgrindSensor.class);
- public static final String REPORT_PATH_KEY = "sonar.cxx.valgrind.reportPath";
+ public static final String REPORT_PATH_KEY = "valgrind.reportPath";
+ public static String KEY = "Valgrind";
/**
* {@inheritDoc}
*/
- public CxxValgrindSensor(Settings settings) {
- super(settings, CxxMetrics.VALGRIND);
+ public CxxValgrindSensor(CxxLanguage language) {
+ super(language);
}
- @Override
protected String reportPathKey() {
return REPORT_PATH_KEY;
}
@@ -60,7 +58,7 @@ protected void processReport(final SensorContext context, File report)
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxValgrindSensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxValgrindSensor");
}
void saveErrors(SensorContext context, Set valgrindErrors) {
@@ -74,4 +72,9 @@ void saveErrors(SensorContext context, Set valgrindErrors) {
}
}
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindError.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindError.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindError.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindError.java
index 30b9e31aa1..5001d9f800 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindError.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindError.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.valgrind;
+package org.sonar.cxx.sensors.valgrind;
import org.apache.commons.lang.builder.HashCodeBuilder;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindFrame.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindFrame.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindFrame.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindFrame.java
index 52ab98cced..2581b0ba24 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindFrame.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindFrame.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.valgrind;
+package org.sonar.cxx.sensors.valgrind;
import java.io.File;
import org.apache.commons.io.FilenameUtils;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindReportParser.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParser.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindReportParser.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParser.java
index 751644ffc8..1b9d1ba3fe 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindReportParser.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindReportParser.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.valgrind;
+package org.sonar.cxx.sensors.valgrind;
import java.io.File;
import java.util.HashSet;
@@ -26,8 +26,8 @@
import org.codehaus.staxmate.in.SMHierarchicCursor;
import org.codehaus.staxmate.in.SMInputCursor;
import org.sonar.api.batch.sensor.SensorContext;
-import org.sonar.plugins.cxx.utils.EmptyReportException;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.sensors.utils.EmptyReportException;
+import org.sonar.cxx.sensors.utils.StaxParser;
class ValgrindReportParser {
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindStack.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindStack.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindStack.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindStack.java
index 9741645334..acdb5fc633 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/ValgrindStack.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/ValgrindStack.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.valgrind;
+package org.sonar.cxx.sensors.valgrind;
import java.util.ArrayList;
import java.util.List;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/package-info.java
index ef8a797eb3..312602149c 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/valgrind/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/valgrind/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate Valgrind specific report files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.valgrind;
+package org.sonar.cxx.sensors.valgrind;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxRuleRepository.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/veraxx/CxxVeraxxRuleRepository.java
similarity index 80%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxRuleRepository.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/veraxx/CxxVeraxxRuleRepository.java
index 1450c8e4ce..0358cc9c35 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxRuleRepository.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/veraxx/CxxVeraxxRuleRepository.java
@@ -17,12 +17,13 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.veraxx;
+package org.sonar.cxx.sensors.veraxx;
import org.sonar.api.config.Settings;
import org.sonar.api.platform.ServerFileSystem;
import org.sonar.api.server.rule.RulesDefinitionXmlLoader;
-import org.sonar.plugins.cxx.utils.CxxAbstractRuleRepository;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxAbstractRuleRepository;
/**
* {@inheritDoc}
@@ -30,14 +31,14 @@
public class CxxVeraxxRuleRepository extends CxxAbstractRuleRepository {
static final String KEY = "vera++";
- public static final String CUSTOM_RULES_KEY = "sonar.cxx.vera++.customRules";
+ public static final String CUSTOM_RULES_KEY = "vera++.customRules";
private static final String NAME = "Vera++";
/**
* {@inheritDoc}
*/
- public CxxVeraxxRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, Settings settings) {
- super(fileSystem, xmlRuleLoader, settings, KEY, NAME, CUSTOM_RULES_KEY);
+ public CxxVeraxxRuleRepository(ServerFileSystem fileSystem, RulesDefinitionXmlLoader xmlRuleLoader, CxxLanguage language) {
+ super(fileSystem, xmlRuleLoader, KEY, NAME, CUSTOM_RULES_KEY, language);
}
@Override
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxSensor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/veraxx/CxxVeraxxSensor.java
similarity index 84%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxSensor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/veraxx/CxxVeraxxSensor.java
index dc6dbc4a68..58ab1b7736 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/CxxVeraxxSensor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/veraxx/CxxVeraxxSensor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.veraxx;
+package org.sonar.cxx.sensors.veraxx;
import java.io.File;
@@ -25,30 +25,28 @@
import org.codehaus.staxmate.in.SMInputCursor;
import org.sonar.api.batch.sensor.SensorContext;
import org.sonar.api.batch.sensor.SensorDescriptor;
-import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
import org.sonar.api.utils.log.Loggers;
-import org.sonar.plugins.cxx.CxxLanguage;
-import org.sonar.plugins.cxx.utils.CxxMetrics;
-import org.sonar.plugins.cxx.utils.CxxReportSensor;
-import org.sonar.plugins.cxx.utils.CxxUtils;
-import org.sonar.plugins.cxx.utils.EmptyReportException;
-import org.sonar.plugins.cxx.utils.StaxParser;
+import org.sonar.cxx.CxxLanguage;
+import org.sonar.cxx.sensors.utils.CxxReportSensor;
+import org.sonar.cxx.sensors.utils.CxxUtils;
+import org.sonar.cxx.sensors.utils.EmptyReportException;
+import org.sonar.cxx.sensors.utils.StaxParser;
/**
* {@inheritDoc}
*/
public class CxxVeraxxSensor extends CxxReportSensor {
- public static final Logger LOG = Loggers.get(CxxVeraxxSensor.class);
+ public static final Logger LOG = Loggers.get(CxxVeraxxSensor.class);
+ public static final String REPORT_PATH_KEY = "vera.reportPath";
+ public static String KEY = "Vera++";
- public static final String REPORT_PATH_KEY = "sonar.cxx.vera.reportPath";
-
/**
* {@inheritDoc}
*/
- public CxxVeraxxSensor(Settings settings) {
- super(settings, CxxMetrics.VERAXX);
+ public CxxVeraxxSensor(CxxLanguage language) {
+ super(language);
}
@Override
@@ -58,7 +56,7 @@ protected String reportPathKey() {
@Override
public void describe(SensorDescriptor descriptor) {
- descriptor.onlyOnLanguage(CxxLanguage.KEY).name("CxxVeraxxSensor");
+ descriptor.onlyOnLanguage(this.language.getKey()).name("CxxVeraxxSensor");
}
@Override
@@ -108,4 +106,9 @@ public void stream(SMHierarchicCursor rootCursor) throws javax.xml.stream.XMLStr
LOG.error("Ignore XML error from Veraxx '{}'", CxxUtils.getStackTrace(e));
}
}
+
+ @Override
+ protected String getSensorKey() {
+ return KEY;
+ }
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/veraxx/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/veraxx/package-info.java
index 4013d4a46a..be32ec9edc 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/veraxx/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/veraxx/package-info.java
@@ -22,6 +22,6 @@
* Package with sensor to evaluate Veraxx specific report files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.veraxx;
+package org.sonar.cxx.sensors.veraxx;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cpd/CxxCpdVisitor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxCpdVisitor.java
similarity index 98%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cpd/CxxCpdVisitor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxCpdVisitor.java
index e968797857..2e70bc3e4f 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cpd/CxxCpdVisitor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxCpdVisitor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.cpd;
+package org.sonar.cxx.sensors.visitors;
import java.io.File;
import javax.annotation.Nullable;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/highlighter/CxxHighlighter.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxHighlighterVisitor.java
similarity index 95%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/highlighter/CxxHighlighter.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxHighlighterVisitor.java
index 7dee0d00d7..46698c0c3b 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/highlighter/CxxHighlighter.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/CxxHighlighterVisitor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.highlighter;
+package org.sonar.cxx.sensors.visitors;
import javax.annotation.Nullable;
import com.sonar.sslr.api.AstAndTokenVisitor;
@@ -37,9 +37,9 @@
import org.sonar.cxx.api.CxxTokenType;
import org.sonar.cxx.api.CxxKeyword;
-public class CxxHighlighter extends SquidAstVisitor implements AstAndTokenVisitor {
+public class CxxHighlighterVisitor extends SquidAstVisitor implements AstAndTokenVisitor {
- private static final Logger LOG = Loggers.get(CxxHighlighter.class);
+ private static final Logger LOG = Loggers.get(CxxHighlighterVisitor.class);
private NewHighlighting newHighlighting;
private final SensorContext context;
@@ -114,7 +114,7 @@ private class PreprocessorDirectiveLocation extends TokenLocation {
}
}
- public CxxHighlighter(SensorContext context) {
+ public CxxHighlighterVisitor(SensorContext context) {
this.context = context;
}
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/metrics/FileLinesVisitor.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/FileLinesVisitor.java
similarity index 99%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/metrics/FileLinesVisitor.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/FileLinesVisitor.java
index da817c0a03..26c7987855 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/metrics/FileLinesVisitor.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/FileLinesVisitor.java
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-package org.sonar.plugins.cxx.metrics;
+package org.sonar.cxx.sensors.visitors;
import com.google.common.collect.Sets;
import com.sonar.sslr.api.AstAndTokenVisitor;
diff --git a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cpd/package-info.java b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/package-info.java
similarity index 96%
rename from sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cpd/package-info.java
rename to cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/package-info.java
index 020fd2adf7..06c0e996b5 100644
--- a/sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/cpd/package-info.java
+++ b/cxx-sensors/src/main/java/org/sonar/cxx/sensors/visitors/package-info.java
@@ -22,6 +22,6 @@
* Package with visitor to define tokens used by CPD algorithm on files.
*/
@ParametersAreNonnullByDefault
-package org.sonar.plugins.cxx.cpd;
+package org.sonar.cxx.sensors.visitors;
import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/sonar-cxx-plugin/src/main/resources/clangtidy.xml b/cxx-sensors/src/main/resources/clangtidy.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/clangtidy.xml
rename to cxx-sensors/src/main/resources/clangtidy.xml
diff --git a/sonar-cxx-plugin/src/main/resources/compiler-gcc.xml b/cxx-sensors/src/main/resources/compiler-gcc.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/compiler-gcc.xml
rename to cxx-sensors/src/main/resources/compiler-gcc.xml
diff --git a/sonar-cxx-plugin/src/main/resources/compiler-vc.xml b/cxx-sensors/src/main/resources/compiler-vc.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/compiler-vc.xml
rename to cxx-sensors/src/main/resources/compiler-vc.xml
diff --git a/sonar-cxx-plugin/src/main/resources/cppcheck.xml b/cxx-sensors/src/main/resources/cppcheck.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/cppcheck.xml
rename to cxx-sensors/src/main/resources/cppcheck.xml
diff --git a/sonar-cxx-plugin/src/main/resources/drmemory.xml b/cxx-sensors/src/main/resources/drmemory.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/drmemory.xml
rename to cxx-sensors/src/main/resources/drmemory.xml
diff --git a/sonar-cxx-plugin/src/main/resources/external-rule.xml b/cxx-sensors/src/main/resources/external-rule.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/external-rule.xml
rename to cxx-sensors/src/main/resources/external-rule.xml
diff --git a/sonar-cxx-plugin/src/main/resources/external/intel_inspector_rules.xml b/cxx-sensors/src/main/resources/external/intel_inspector_rules.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/external/intel_inspector_rules.xml
rename to cxx-sensors/src/main/resources/external/intel_inspector_rules.xml
diff --git a/sonar-cxx-plugin/src/main/resources/macros/GxxMacros.h b/cxx-sensors/src/main/resources/macros/GxxMacros.h
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/macros/GxxMacros.h
rename to cxx-sensors/src/main/resources/macros/GxxMacros.h
diff --git a/sonar-cxx-plugin/src/main/resources/macros/VS10Macros.h b/cxx-sensors/src/main/resources/macros/VS10Macros.h
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/macros/VS10Macros.h
rename to cxx-sensors/src/main/resources/macros/VS10Macros.h
diff --git a/sonar-cxx-plugin/src/main/resources/pclint.xml b/cxx-sensors/src/main/resources/pclint.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/pclint.xml
rename to cxx-sensors/src/main/resources/pclint.xml
diff --git a/sonar-cxx-plugin/src/main/resources/rats.xml b/cxx-sensors/src/main/resources/rats.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/rats.xml
rename to cxx-sensors/src/main/resources/rats.xml
diff --git a/sonar-cxx-plugin/src/main/resources/rules.xsd b/cxx-sensors/src/main/resources/rules.xsd
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/rules.xsd
rename to cxx-sensors/src/main/resources/rules.xsd
diff --git a/sonar-cxx-plugin/src/main/resources/valgrind.xml b/cxx-sensors/src/main/resources/valgrind.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/valgrind.xml
rename to cxx-sensors/src/main/resources/valgrind.xml
diff --git a/sonar-cxx-plugin/src/main/resources/vera++.xml b/cxx-sensors/src/main/resources/vera++.xml
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/vera++.xml
rename to cxx-sensors/src/main/resources/vera++.xml
diff --git a/sonar-cxx-plugin/src/main/resources/xsl/boosttest-1.x-to-junit-1.0.xsl b/cxx-sensors/src/main/resources/xsl/boosttest-1.x-to-junit-1.0.xsl
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/xsl/boosttest-1.x-to-junit-1.0.xsl
rename to cxx-sensors/src/main/resources/xsl/boosttest-1.x-to-junit-1.0.xsl
diff --git a/sonar-cxx-plugin/src/main/resources/xsl/boosttest-1.x-to-junit-dummy-1.0.xsl b/cxx-sensors/src/main/resources/xsl/boosttest-1.x-to-junit-dummy-1.0.xsl
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/xsl/boosttest-1.x-to-junit-dummy-1.0.xsl
rename to cxx-sensors/src/main/resources/xsl/boosttest-1.x-to-junit-dummy-1.0.xsl
diff --git a/sonar-cxx-plugin/src/main/resources/xsl/cpptestunit-1.x-to-junit-1.0.xsl b/cxx-sensors/src/main/resources/xsl/cpptestunit-1.x-to-junit-1.0.xsl
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/xsl/cpptestunit-1.x-to-junit-1.0.xsl
rename to cxx-sensors/src/main/resources/xsl/cpptestunit-1.x-to-junit-1.0.xsl
diff --git a/sonar-cxx-plugin/src/main/resources/xsl/cppunit-1.x-to-junit-1.0.xsl b/cxx-sensors/src/main/resources/xsl/cppunit-1.x-to-junit-1.0.xsl
similarity index 100%
rename from sonar-cxx-plugin/src/main/resources/xsl/cppunit-1.x-to-junit-1.0.xsl
rename to cxx-sensors/src/main/resources/xsl/cppunit-1.x-to-junit-1.0.xsl
diff --git a/cxx-sensors/src/samples/SampleProject/.gitignore b/cxx-sensors/src/samples/SampleProject/.gitignore
new file mode 100644
index 0000000000..62f5356cc3
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/.gitignore
@@ -0,0 +1,2 @@
+*-reports
+builds
diff --git a/cxx-sensors/src/samples/SampleProject/Build.xml b/cxx-sensors/src/samples/SampleProject/Build.xml
new file mode 100644
index 0000000000..46fe34c3ff
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/Build.xml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cxx-sensors/src/samples/SampleProject/pom.xml b/cxx-sensors/src/samples/SampleProject/pom.xml
new file mode 100644
index 0000000000..993dc9b63d
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/pom.xml
@@ -0,0 +1,550 @@
+
+
+ 4.0.0
+ NETICOA
+ SAMPLE
+ 0.0.1-SNAPSHOT
+ pom
+ SAMPLE
+
+
+
+ RELEASE
+
+ true
+
+ release
+
+
+
+ src/test/java
+
+
+
+
+
+ org.codehaus.mojo
+ cxx-maven-plugin
+ 0.0.5-SNAPSHOT
+
+
+
+
+
+ org.codehaus.mojo
+ cxx-maven-plugin
+
+
+ clean
+ clean
+
+ launch
+
+
+ rm
+ -rf "${basedir}/builds/Unix Makefiles/RELEASE"
+
+
+
+ cmake
+
+
+
+ cmake
+
+
+
+ ${basedir}/sources
+
+ ${basedir}/builds/Unix Makefiles/RELEASE
+ "Unix Makefiles"
+ -DPROJECT_TARGET="RELEASE" -DEXECUTABLE_NAME="SAMPLE" -DPROJECT_LANGUAGE="en" -DCMAKE_BUILD_TYPE="Release"
+
+
+
+ make
+
+
+
+ make
+
+
+ ${basedir}/builds/Unix Makefiles/RELEASE
+
+
+
+ unit-test
+
+
+
+ xunit
+
+
+ sh
+ ${basedir}/builds/Unix Makefiles/RELEASE/bin
+ "${basedir}/scripts/execUnitTest.sh" ./SAMPLE-PROJECT-TESTS "${basedir}/xunit-reports/xunit-result-SAMPLE.xml"
+
+
+
+ cppcheck
+
+
+
+ cppcheck
+
+
+
+
+
+ ${basedir}/builds/Unix Makefiles/RELEASE/application
+
+
+
+ -j3
+
+
+ SAMPLE
+
+
+
+
+ veraxx
+
+
+
+ veraxx
+
+
+
+
+ SAMPLE
+
+
+
+
+
+
+
+
+ sources/application
+ sources/utils
+ sources/tests
+
+
+
+
+
+
+
+
+
+
+ COVERAGE
+
+
+ coverage
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ cxx-maven-plugin
+ 0.0.5-SNAPSHOT
+
+
+
+
+
+
+ org.codehaus.mojo
+ cxx-maven-plugin
+
+
+ clean
+ clean
+
+ launch
+
+
+ rm
+ -rf "${basedir}/builds/Unix Makefiles/COVERAGE"
+
+
+
+ cmake
+
+
+
+ cmake
+
+
+
+ ${basedir}/sources
+
+ ${basedir}/builds/Unix Makefiles/COVERAGE
+ "Unix Makefiles"
+ -DPROJECT_TARGET="COVERAGE" -DEXECUTABLE_NAME="SAMPLE" -DPROJECT_LANGUAGE="en" -DCMAKE_BUILD_TYPE="Coverage"
+
+
+
+ make
+
+
+
+ make
+
+
+ ${basedir}/builds/Unix Makefiles/COVERAGE
+
+
+
+ coverage-test
+
+
+
+ coverage
+
+
+
+ -r ${basedir} -x -d -e ".*QtCore.*" -e ".*QtGui.*" -e ".*QtTest.*"
+ sh
+ ${basedir}/builds/Unix Makefiles/COVERAGE
+ "${basedir}/scripts/execUnitTest.sh" ./bin/SAMPLE-PROJECT-TESTS "${basedir}/xunit-reports/xunit-result-SAMPLE.xml"
+ SAMPLE
+
+
+
+ valgrind-test
+
+
+
+ valgrind
+
+
+ ${basedir}/builds/Unix Makefiles/COVERAGE
+ ${basedir}/builds/Unix Makefiles/COVERAGE/bin/SAMPLE-PROJECT-TESTS
+ SAMPLE
+
+
+
+
+ cppcheck
+
+
+
+ cppcheck
+
+
+
+ ${basedir}/builds/Unix Makefiles/COVERAGE/application
+
+ SAMPLE
+
+
+
+
+ veraxx
+
+
+
+ veraxx
+
+
+ SAMPLE
+
+
+
+
+
+
+
+
+
+ sources/application
+ sources/utils
+ sources/tests
+
+
+
+
+
+
+
+
+
+ WINCOVERAGE
+
+
+ wincoverage
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ cxx-maven-plugin
+ 0.0.5-SNAPSHOT
+
+
+
+
+
+
+ org.codehaus.mojo
+ cxx-maven-plugin
+
+
+ clean
+ clean
+
+ launch
+
+
+ rm
+ -rf "${basedir}/builds/Unix Makefiles/COVERAGE"
+
+
+
+ cmake
+
+
+
+ cmake
+
+
+
+ ${basedir}/sources
+
+ ${basedir}/builds/Unix Makefiles/COVERAGE
+ "MinGW Makefiles"
+ -DPROJECT_TARGET="COVERAGE" -DEXECUTABLE_NAME="SAMPLE" -DPROJECT_LANGUAGE="en" -DCMAKE_BUILD_TYPE="Coverage"
+
+
+
+ make
+
+
+
+ make
+
+
+
+ mingw32-make
+ mingw32-make
+
+ ${basedir}/builds/Unix Makefiles/COVERAGE
+
+
+
+ coverage-test
+
+
+
+ coverage
+
+
+
+ -r ${basedir} -x -d -e ".*QtCore.*" -e ".*QtGui.*" -e ".*QtTest.*"
+ bash
+ ${basedir}/builds/Unix Makefiles/COVERAGE
+ "${basedir}/scripts/execUnitTest.sh" ./bin/SAMPLE-PROJECT-TESTS "${basedir}/xunit-reports/xunit-result-SAMPLE.xml"
+ SAMPLE
+
+
+
+
+
+
+
+
+ sources/application
+ sources/utils
+ sources/tests
+
+
+
+
+
+
+
+
+
+ WINRELEASE
+
+
+ winrelease
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ cxx-maven-plugin
+ 0.0.5-SNAPSHOT
+
+
+
+
+
+
+ org.codehaus.mojo
+ cxx-maven-plugin
+
+
+ clean
+ clean
+
+ launch
+
+
+ rm
+ -rf "${basedir}/builds/Unix Makefiles/RELEASE"
+
+
+
+ cmake
+
+
+
+ cmake
+
+
+
+ ${basedir}/sources
+
+ ${basedir}/builds/Unix Makefiles/RELEASE
+ "MinGW Makefiles"
+ -DPROJECT_TARGET="RELEASE" -DEXECUTABLE_NAME="SAMPLE" -DPROJECT_LANGUAGE="en" -DCMAKE_BUILD_TYPE="Release"
+
+
+
+ make
+
+
+
+ make
+
+
+
+ mingw32-make
+ mingw32-make
+
+ ${basedir}/builds/Unix Makefiles/RELEASE
+
+
+
+ unit-test
+
+
+
+ xunit
+
+
+ bash
+ ${basedir}/builds/Unix Makefiles/RELEASE/bin
+ "${basedir}/scripts/execUnitTest.sh" ./SAMPLE-PROJECT-TESTS "${basedir}/xunit-reports/xunit-result-SAMPLE.xml"
+
+
+
+
+
+
+
+
+
+ sources/application
+ sources/utils
+ sources/tests
+
+
+
+
+
+
+
+
+
+
+
+ sources
+
+
+ c++
+ reuseReports
+ true
+ scm:svn:https://svn.codehaus.org/sonar-plugins/trunk/cxx/src/sample/SampleProject
+
+ cppcheck-reports/cppcheck-result-*.xml
+ gcovr-reports/gcovr-result-*.xml
+ gcovr-reports/gcovr-result-*.xml
+ gcovr-reports/gcovr-result-*.xml
+ rats-reports/rats-result-*.xml
+ vera++-reports/vera++-result-*.xml
+ xunit-reports/xunit-result-*.xml
+
+ Q_OBJECT, Q_SLOTS
+ sources/tests
+
+
+
+
+
+
+
diff --git a/cxx-sensors/src/samples/SampleProject/rats.sh b/cxx-sensors/src/samples/SampleProject/rats.sh
new file mode 100644
index 0000000000..e50cea716e
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/rats.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+reports_directory="rats-reports"
+report_filename="rats-result-SAMPLE.xml"
+if [ ! -e $reports_directory ]; then
+ mkdir $reports_directory
+fi
+rats -w 3 --xml sources > $report_filename
+mv $report_filename $reports_directory
diff --git a/cxx-sensors/src/samples/SampleProject/scripts/execUnitTest.sh b/cxx-sensors/src/samples/SampleProject/scripts/execUnitTest.sh
new file mode 100644
index 0000000000..10e3133730
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/scripts/execUnitTest.sh
@@ -0,0 +1,18 @@
+#!/bin/sh -f
+
+EXECUTABLEPATH=".\SAMPLE-PROJECT-TESTS"
+REPORTFILEPATH=".\TEST-result-SAMPLE.xml"
+
+if [ $# -ge 1 ]; then
+ EXECUTABLEPATH=$1
+fi
+if [ $# -ge 2 ]; then
+ REPORTFILEPATH=$2
+fi
+
+# create full report path location
+echo "Create directiory `echo "$REPORTFILEPATH" | sed -r "s/(.*\/).*/\1/"`"
+mkdir -p "`echo "$REPORTFILEPATH" | sed -r "s/(.*\/).*/\1/"`"
+
+
+"$EXECUTABLEPATH" -xunitxml -o "$REPORTFILEPATH"
diff --git a/cxx-sensors/src/samples/SampleProject/sonar-project.properties b/cxx-sensors/src/samples/SampleProject/sonar-project.properties
new file mode 100644
index 0000000000..e5d43cf608
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sonar-project.properties
@@ -0,0 +1,20 @@
+# required metadata
+sonar.projectKey=NETICOA:SAMPLE
+sonar.projectName=SAMPLE
+sonar.projectVersion=0.0.1-SNAPSHOT
+sonar.language=c++
+
+# path to source directories (required)
+sources=sources
+
+# path to test source directories (optional)
+#tests=testDir1,testDir2
+
+# path to project binaries (optional), for example directory of Java bytecode
+#binaries=binDir
+
+# path to project libraries (optional)
+#libraries=junit.jar
+
+# advanced parameters
+#my.property=value
diff --git a/cxx-sensors/src/samples/SampleProject/sources/CMakeLists.txt b/cxx-sensors/src/samples/SampleProject/sources/CMakeLists.txt
new file mode 100644
index 0000000000..4fc5ac52d0
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/CMakeLists.txt
@@ -0,0 +1,120 @@
+########################################################################################
+########################################################################################
+# CMAKE SAMPLE ROOT
+#
+# This CMAKE file provides the WHOLE configuration of the SAMPLE project
+# see http://www.cmake.org/cmake/help/cmake-2-8-docs.html
+# see http://www.vtk.org/Wiki/CMake_Useful_Variables
+########################################################################################
+########################################################################################
+
+########################################################################################
+# CMAKE MANAGEMENT - DO NOT MODIFY
+
+# Check the CMAKE version on the developer PC
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+# Don't build anything unless the version of CMake is high enough.
+# The matching ELSE/ENDIF should be the last lines in the file.
+IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.4)
+
+# Allow IF/ELSE/ELSEIF/ENDIF with empty values (superfluous in 2.6.0)
+#SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+# remove cmakelists.txt files from generated solutions
+SET(CMAKE_SUPPRESS_REGENERATION true)
+
+########################################################################################
+# PROJECT NAME
+
+# Sets the name of the project.
+# This creates the variables projectname_BINARY_DIR and projectname_SOURCE_DIR.
+PROJECT (SAMPLE-PROJECT)
+
+IF(NOT PROJECT_TARGET)
+SET(PROJECT_TARGET "SAMPLE_GENERIQUE")
+ENDIf(NOT PROJECT_TARGET)
+
+IF(NOT EXECUTABLE_NAME)
+SET(EXECUTABLE_NAME "SAMPLE")
+ENDIf(NOT EXECUTABLE_NAME)
+
+IF(NOT PROJECT_LANGUAGE)
+SET(PROJECT_LANGUAGE "en")
+ENDIf(NOT PROJECT_LANGUAGE)
+
+MESSAGE("Building ${CMAKE_GENERATOR} for ${PROJECT_TARGET}, executable ${EXECUTABLE_NAME}, language ${PROJECT_LANGUAGE}")
+MESSAGE("CXX_FLAGS='${CMAKE_CXX_FLAGS}', C_FLAGS='${CMAKE_C_FLAGS}'")
+IF(${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "MinGW Makefiles")
+ IF(${CMAKE_BUILD_TYPE} MATCHES "Release")
+ MESSAGE("Release Build, CXX_FLAGS_RELEASE='${CMAKE_CXX_FLAGS_RELEASE}', C_FLAGS_RELEASE='${CMAKE_C_FLAGS_RELEASE}'")
+ MESSAGE("Makefile build type can change using cmake option -DCMAKE_BUILD_TYPE=Debug,Release,Coverage instead of '${CMAKE_BUILD_TYPE}'")
+ ELSEIF(${CMAKE_BUILD_TYPE} MATCHES "Debug")
+ MESSAGE("Debug Build, CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}', C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'")
+ MESSAGE("Makefile build type can change using cmake option -DCMAKE_BUILD_TYPE=Debug,Release,Coverage instead of '${CMAKE_BUILD_TYPE}'")
+ ELSEIF(${CMAKE_BUILD_TYPE} MATCHES "Coverage")
+ SET(CMAKE_BUILD_TYPE "Debug")
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fprofile-arcs -ftest-coverage")
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs")
+ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs")
+ SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fprofile-arcs")
+ MESSAGE("Coverage Debug Build, CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}', C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'")
+ MESSAGE("Makefile build type can change using cmake option -DCMAKE_BUILD_TYPE=Debug,Release,Coverage instead of '${CMAKE_BUILD_TYPE}'")
+ ELSEIF(NOT CMAKE_BUILD_TYPE)
+ MESSAGE("Concider using cmake option -DCMAKE_BUILD_TYPE=Debug,Release,Coverage instead of '${CMAKE_BUILD_TYPE}'")
+ ENDIF()
+ELSE()
+ MESSAGE("For Debug Build, CXX_FLAGS_DEBUG='${CMAKE_CXX_FLAGS_DEBUG}', C_FLAGS_DEBUG='${CMAKE_C_FLAGS_DEBUG}'")
+ MESSAGE("For Release Build, CXX_FLAGS_RELEASE='${CMAKE_CXX_FLAGS_RELEASE}', C_FLAGS_RELEASE='${CMAKE_C_FLAGS_RELEASE}'")
+ENDIF()
+
+
+########################################################################################
+# TARGET FLAGS
+
+# Add your own DEFINE here !
+
+# Compute the LANGUAGE define
+STRING( TOUPPER BUILD_${PROJECT_LANGUAGE} BUILD_LANGUAGE )
+
+########################################################################################
+# OUTPUT PATH
+
+# Create Directories if not exist
+FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR})
+
+SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
+SET(LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH})
+
+# Create Directories if not exist)
+FILE(MAKE_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
+FILE(MAKE_DIRECTORY ${LIBRARY_OUTPUT_PATH})
+
+########################################################################################
+# PROJECTS LIST
+
+# Add your new project/module in this list !
+SUBDIRS(
+ # Project : tests
+ tests
+
+ # Project : Main SAMPLE
+ application
+
+ # Project : utils
+ utils
+
+ # other sub dir here
+)
+
+########################################################################################
+# CMAKE MANAGEMENT - DO NOT MODIFY
+
+# If the version of CMake was too old, complain and build nothing.
+# These should be the last lines in this file.
+ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.4)
+ MESSAGE(FATAL_ERROR
+ "This version of CMake is too old to build the software. Please upgrade to CMake 2.6.")
+ENDIF()
+
diff --git a/cxx-sensors/src/samples/SampleProject/sources/application/CMakeLists.txt b/cxx-sensors/src/samples/SampleProject/sources/application/CMakeLists.txt
new file mode 100644
index 0000000000..9c0487f585
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/application/CMakeLists.txt
@@ -0,0 +1,117 @@
+########################################################################################
+########################################################################################
+# CMAKE PROJECT
+########################################################################################
+########################################################################################
+PROJECT (SAMPLE)
+
+########################################################################################
+# C++ INCLUDE DIRECTORIES
+
+# Add a new include path in this list !
+INCLUDE_DIRECTORIES (
+ ${PROJECT_SOURCE_DIR}
+ ${PROJECT_SOURCE_DIR}/..
+ ${PROJECT_BINARY_DIR} # for uic included generated files
+)
+
+########################################################################################
+# INTERNAL SOURCE LOCATION (source that are not visible from outside)
+
+# Set the base directory of your source files
+SET(SAMPLE_MAIN_DIR_SRCS "." )
+
+# Add your source files here !
+SET(SAMPLE_MAIN_SRCS
+ "${SAMPLE_MAIN_DIR_SRCS}/main.cpp"
+)
+
+# Add your header files here !
+SET(SAMPLE_MAIN_HDRS)
+
+# Add your header files here !
+SET(SAMPLE_MAIN_QT_HDRS)
+
+# Add your source files here !
+SET(SAMPLE_UI_SRCS)
+
+# Add your header files here !
+SET(SAMPLE_UI_HDRS)
+
+# Add your resource files here !
+SET(SAMPLE_UI_QRC)
+
+# Add your ui files here !
+SET(SAMPLE_UI_UI)
+
+# Add your header files here !
+SET(SAMPLE_UI_NO_QOBJECT_HDRS)
+
+
+########################################################################################
+# QT PROJECT MOC/QRC/UI STUFF
+
+FIND_PACKAGE( Qt4 REQUIRED )
+
+SET(QT_USE_QTNETWORK FALSE)
+SET(QT_USE_QTOPENGL FALSE)
+SET(QT_USE_QTSQL FALSE)
+SET(QT_USE_QTXML FALSE)
+SET(QT_USE_QTSVG FALSE)
+SET(QT_USE_QTTEST FALSE)
+SET(QT_USE_QTDBUS FALSE)
+SET(QT_USE_QTSCRIPT FALSE)
+SET(QT_USE_QTWEBKIT FALSE)
+SET(QT_USE_QTXMLPATTERNS FALSE)
+SET(QT_USE_PHONON FALSE)
+
+INCLUDE(${QT_USE_FILE})
+
+# Add your QT resource file here !
+QT4_ADD_RESOURCES( SAMPLE_QRC_SRCS
+ ${SAMPLE_UI_QRC})
+
+# Add your QT headers file here !
+QT4_WRAP_CPP(SAMPLE_MOC_SRCS
+ ${SAMPLE_MAIN_QT_HDRS}
+ ${SAMPLE_QAPPLICATION_QOBJ_HDRS}
+ ${SAMPLE_UI_HDRS}
+)
+
+# Add your QT Ui file here
+QT4_WRAP_UI( SAMPLE_UIC_SRCS
+ ${SAMPLE_UI_UI})
+
+########################################################################################
+# BINARY TARGET
+
+SET(SAMPLE_EXECUTABLE_NAME ${EXECUTABLE_NAME})
+
+# Executable parameters depends on PF
+IF(WIN32)
+ SET(SAMPLE_EXECUTABLE_TYPE WIN32)
+ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ SET(SAMPLE_EXECUTABLE_TYPE MACOSX_BUNDLE)
+ENDIF()
+
+# SAMPLE is a program that depends on sources code (headers are mentionned only to appear in IDE)
+ADD_EXECUTABLE(${SAMPLE_EXECUTABLE_NAME}
+ ${SAMPLE_EXECUTABLE_TYPE}
+ ${SAMPLE_MAIN_SRCS}
+ ${SAMPLE_MAIN_HDRS}
+ ${SAMPLE_UI_SRCS}
+ ${SAMPLE_UI_HDRS}
+ ${SAMPLE_UI_NO_QOBJECT_HDRS}
+ ${SAMPLE_QRC_SRCS}
+ ${SAMPLE_MOC_SRCS}
+ ${SAMPLE_UIC_SRCS}
+)
+
+########################################################################################
+# LINK WITH OTHER LIBRARIES
+
+# SAMPLE depends on QT and ...
+TARGET_LINK_LIBRARIES( ${SAMPLE_EXECUTABLE_NAME}
+ ${QT_LIBRARIES}
+)
+
diff --git a/cxx-sensors/src/samples/SampleProject/sources/application/main.cpp b/cxx-sensors/src/samples/SampleProject/sources/application/main.cpp
new file mode 100644
index 0000000000..316223e344
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/application/main.cpp
@@ -0,0 +1,9 @@
+#include
+
+int main(int argc, char *argv[])
+{
+ new int(); //memleak
+
+ QApplication app(argc, argv);
+ return app.exec();
+}
diff --git a/cxx-sensors/src/samples/SampleProject/sources/tests/CMakeLists.txt b/cxx-sensors/src/samples/SampleProject/sources/tests/CMakeLists.txt
new file mode 100644
index 0000000000..07ef3b127c
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/tests/CMakeLists.txt
@@ -0,0 +1,124 @@
+########################################################################################
+########################################################################################
+# CMAKE PROJECT
+########################################################################################
+########################################################################################
+PROJECT (SAMPLE-PROJECT-TESTS)
+
+########################################################################################
+# C++ INCLUDE DIRECTORIES
+
+# Add a new include path in this list !
+INCLUDE_DIRECTORIES (
+ ${PROJECT_SOURCE_DIR}
+ ${PROJECT_SOURCE_DIR}/..
+ ${PROJECT_BINARY_DIR} # for uic included generated files
+)
+
+########################################################################################
+# INTERNAL SOURCE LOCATION (source that are not visible from outside)
+
+# Set the base directory of your source files
+SET(SAMPLE_PROJECT_TESTS_MAIN_DIR_SRCS "." )
+
+
+# Add your source files here !
+SET(SAMPLE_PROJECT_TESTS_MAIN_SRCS
+ "${SAMPLE_PROJECT_TESTS_MAIN_DIR_SRCS}/main.cpp"
+ "${SAMPLE_PROJECT_TESTS_MAIN_DIR_SRCS}/SAMPLE-test.cpp"
+)
+
+# Add your header files here !
+SET(SAMPLE_PROJECT_TESTS_MAIN_HDRS
+)
+
+# Add your header files here !
+SET(SAMPLE_PROJECT_TESTS_MAIN_QT_HDRS
+ "${SAMPLE_PROJECT_TESTS_MAIN_DIR_SRCS}/SAMPLE-test.h"
+)
+
+# Add your source files here !
+SET(SAMPLE_PROJECT_TESTS_UI_SRCS
+)
+
+# Add your header files here !
+SET(SAMPLE_PROJECT_TESTS_UI_HDRS
+)
+
+# Add your resource files here !
+SET(SAMPLE_PROJECT_TESTS_UI_QRC
+)
+
+# Add your ui files here !
+SET(SAMPLE_PROJECT_TESTS_UI_UI
+)
+
+# Add your header files here !
+SET(SAMPLE_PROJECT_TESTS_UI_NO_QOBJECT_HDRS
+)
+
+########################################################################################
+# QT PROJECT MOC/QRC/UI STUFF
+
+FIND_PACKAGE( Qt4 REQUIRED )
+
+SET(QT_USE_QTNETWORK FALSE)
+SET(QT_USE_QTOPENGL FALSE)
+SET(QT_USE_QTSQL FALSE)
+SET(QT_USE_QTXML TRUE)
+SET(QT_USE_QTSVG FALSE)
+SET(QT_USE_QTTEST TRUE)
+SET(QT_USE_QTDBUS FALSE)
+SET(QT_USE_QTSCRIPT FALSE)
+SET(QT_USE_QTWEBKIT FALSE)
+SET(QT_USE_QTXMLPATTERNS FALSE)
+SET(QT_USE_PHONON FALSE)
+
+INCLUDE(${QT_USE_FILE})
+
+# Add your QT resource file here !
+QT4_ADD_RESOURCES( SAMPLE_PROJECT_TESTS_QRC_SRCS
+ ${SAMPLE_PROJECT_TESTS_UI_QRC})
+
+# Add your QT headers file here !
+QT4_WRAP_CPP(SAMPLE_PROJECT_TESTS_MOC_SRCS
+ ${SAMPLE_PROJECT_TESTS_MAIN_QT_HDRS}
+ ${SAMPLE_PROJECT_TESTS_QAPPLICATION_QOBJ_HDRS}
+ ${SAMPLE_PROJECT_TESTS_UI_HDRS}
+)
+
+# Add your QT Ui file here
+QT4_WRAP_UI( SAMPLE_PROJECT_TESTS_UIC_SRCS
+ ${SAMPLE_PROJECT_TESTS_UI_UI})
+
+########################################################################################
+# BINARY TARGET
+
+# Define the executable name and custom paths (resources & translations)
+SET(SAMPLE_PROJECT_TESTS_EXECUTABLE_NAME SAMPLE-PROJECT-TESTS)
+
+# Executable parameters depends on PF
+IF(WIN32)
+ SET(SAMPLE_PROJECT_TESTS_EXECUTABLE_TYPE WIN32)
+ENDIF()
+
+# SAMPLE_PROJECT_TESTS is a program that depends on sources code (headers are mentionned only to appear in IDE)
+ADD_EXECUTABLE(${SAMPLE_PROJECT_TESTS_EXECUTABLE_NAME}
+ ${SAMPLE_PROJECT_TESTS_EXECUTABLE_TYPE}
+ ${SAMPLE_PROJECT_TESTS_MAIN_SRCS}
+ ${SAMPLE_PROJECT_TESTS_MAIN_HDRS}
+ ${SAMPLE_PROJECT_TESTS_UI_SRCS}
+ ${SAMPLE_PROJECT_TESTS_UI_HDRS}
+ ${SAMPLE_PROJECT_TESTS_UI_NO_QOBJECT_HDRS}
+ ${SAMPLE_PROJECT_TESTS_QRC_SRCS}
+ ${SAMPLE_PROJECT_TESTS_MOC_SRCS}
+ ${SAMPLE_PROJECT_TESTS_UIC_SRCS}
+)
+
+########################################################################################
+# LINK WITH OTHER LIBRARIES
+
+# SAMPLE_PROJECT_TESTS depends on QT and ...
+TARGET_LINK_LIBRARIES( ${SAMPLE_PROJECT_TESTS_EXECUTABLE_NAME}
+ ${QT_LIBRARIES}
+)
diff --git a/cxx-sensors/src/samples/SampleProject/sources/tests/SAMPLE-test.cpp b/cxx-sensors/src/samples/SampleProject/sources/tests/SAMPLE-test.cpp
new file mode 100644
index 0000000000..114a8fbd9a
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/tests/SAMPLE-test.cpp
@@ -0,0 +1,12 @@
+#include
+#include "SAMPLE-test.h"
+
+SAMPLEtest::SAMPLEtest()
+{
+}
+
+void SAMPLEtest::testCase1()
+{
+ new double(); //upps! we leak a double...
+ QVERIFY2(2 == 1 + 1, "math Failure");
+}
diff --git a/cxx-sensors/src/samples/SampleProject/sources/tests/SAMPLE-test.h b/cxx-sensors/src/samples/SampleProject/sources/tests/SAMPLE-test.h
new file mode 100644
index 0000000000..b9aabc4bcb
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/tests/SAMPLE-test.h
@@ -0,0 +1,16 @@
+#ifndef SAMPLETEST_H
+#define SAMPLETEST_H
+#include
+
+class SAMPLEtest : public QObject
+{
+ Q_OBJECT
+
+public:
+ SAMPLEtest();
+
+private Q_SLOTS:
+ void testCase1();
+};
+
+#endif // SAMPLETEST_H
diff --git a/cxx-sensors/src/samples/SampleProject/sources/tests/main.cpp b/cxx-sensors/src/samples/SampleProject/sources/tests/main.cpp
new file mode 100644
index 0000000000..d045d4f2bf
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/tests/main.cpp
@@ -0,0 +1,10 @@
+#include
+#include "SAMPLE-test.h"
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ SAMPLEtest object;
+ QTest::qExec(&object, argc, argv);
+}
diff --git a/cxx-sensors/src/samples/SampleProject/sources/utils/CMakeLists.txt b/cxx-sensors/src/samples/SampleProject/sources/utils/CMakeLists.txt
new file mode 100644
index 0000000000..2cd577bf1e
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/utils/CMakeLists.txt
@@ -0,0 +1,68 @@
+########################################################################################
+########################################################################################
+# CMAKE PROJECT
+########################################################################################
+########################################################################################
+PROJECT (Utils)
+
+########################################################################################
+# C++ INCLUDE DIRECTORIES
+
+# Add a new include path in this list !
+INCLUDE_DIRECTORIES (
+ ${PROJECT_SOURCE_DIR}
+)
+
+########################################################################################
+# INTERNAL SOURCE LOCATION (source that are not visible from outside)
+
+# Set the base directory of your source files
+SET(UTILS_MAIN_DIR_SRCS ".")
+
+# Add your source files here !
+SET(UTILS_SRCS
+ "${UTILS_MAIN_DIR_SRCS}/utils.cpp"
+ "${UTILS_MAIN_DIR_SRCS}/code_chunks.cpp"
+ )
+
+# Add your QObject header files here !
+SET(UTILS_HDRS)
+
+# Add your QObject header files here !
+SET(UTILS_QT_HDRS)
+
+
+########################################################################################
+# QT PROJECT MOC/QRC/UI STUFF
+
+FIND_PACKAGE( Qt4 REQUIRED )
+
+SET(QT_USE_QTNETWORK FALSE)
+SET(QT_USE_QTOPENGL FALSE)
+SET(QT_USE_QTSQL FALSE)
+SET(QT_USE_QTXML FALSE)
+SET(QT_USE_QTSVG FALSE)
+SET(QT_USE_QTTEST FALSE)
+SET(QT_USE_QTDBUS FALSE)
+SET(QT_USE_QTSCRIPT FALSE)
+SET(QT_USE_QTWEBKIT FALSE)
+SET(QT_USE_QTXMLPATTERNS FALSE)
+SET(QT_USE_PHONON FALSE)
+
+INCLUDE(${QT_USE_FILE})
+
+# Add your QT headers file here !
+QT4_WRAP_CPP(UTILS_MOC_SRCS ${UTILS_QT_HDRS})
+
+
+########################################################################################
+# BINARY TARGET
+
+# Create your library target here !
+# utils is a static library that depends on sources code (headers are mentionned only ta appears in vcproj)
+ADD_LIBRARY(Utils STATIC
+ ${UTILS_SRCS}
+ ${UTILS_HDRS}
+ ${UTILS_MOC_SRCS}
+ ${UTILS_QT_HDRS})
+
diff --git a/cxx-sensors/src/samples/SampleProject/sources/utils/code_chunks.cpp b/cxx-sensors/src/samples/SampleProject/sources/utils/code_chunks.cpp
new file mode 100644
index 0000000000..de5f82e9e2
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/utils/code_chunks.cpp
@@ -0,0 +1,87 @@
+#include
+#include
+using namespace std;
+
+//this
+//is
+//a
+//comment
+
+/*
+ this is
+ a
+ multiline
+ comment
+ */
+
+void foo()
+{
+ char buffer[512]; //rats violation
+ gets(buffer); //rats violation
+
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+
+ if(true){
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ cout << "word" << endl;
+ }
+
+ // if(true){
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // cout << "word" << endl;
+ // }
+}
+
+
diff --git a/cxx-sensors/src/samples/SampleProject/sources/utils/utils.cpp b/cxx-sensors/src/samples/SampleProject/sources/utils/utils.cpp
new file mode 100644
index 0000000000..6e54ef0d78
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject/sources/utils/utils.cpp
@@ -0,0 +1,5 @@
+
+int utils()
+{
+ return 0;
+}
diff --git a/cxx-sensors/src/samples/SampleProject2/.gitignore b/cxx-sensors/src/samples/SampleProject2/.gitignore
new file mode 100644
index 0000000000..ade126ac07
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/.gitignore
@@ -0,0 +1,3 @@
+.sonar
+build
+
diff --git a/cxx-sensors/src/samples/SampleProject2/Makefile b/cxx-sensors/src/samples/SampleProject2/Makefile
new file mode 100644
index 0000000000..7e055ac48c
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/Makefile
@@ -0,0 +1,56 @@
+export BUILD_DIR = $(shell "pwd")/build
+
+# Flags passed to the C++ compiler.
+export CXXFLAGS = -g -pthread --coverage
+
+# Flags passed to the linker.
+export LDFLAGS = -pthread --coverage
+
+export CC = g++
+export LD = g++
+export AR = ar
+
+all:
+ @mkdir -p build
+ @$(MAKE) -C src
+ @$(MAKE) -C tests
+
+clean:
+ rm -rf build
+ @$(MAKE) clean -C src
+ @$(MAKE) clean -C tests
+
+
+############################ Sonar-related rules ###############################
+
+sonar: sonar_cppcheck sonar_vera sonar_rats sonar_runtests sonar_coverage sonar_sonar
+
+CPPCHECK_INCLUDES = -Isrc
+SOURCES_TO_ANALYSE = src
+
+# Run cppcheck, a general purpose static code checker
+sonar_cppcheck:
+ cppcheck -v --enable=all --xml $(CPPCHECK_INCLUDES) $(SOURCES_TO_ANALYSE) 2> $(BUILD_DIR)/cppcheck-report.xml
+
+# Run vera: static code checker focusing on code style issues
+sonar_vera:
+ bash -c 'find src -regex ".*\.cc\|.*\.hh" | vera++ - -showrules -nodup |& vera++Report2checkstyleReport.perl > $(BUILD_DIR)/vera++-report.xml'
+
+# Run rats: static code checker focusing on (potential) security problems
+sonar_rats:
+ rats -w 3 --xml $(SOURCES_TO_ANALYSE) > $(BUILD_DIR)/rats-report.xml
+
+# Run some tests. This run provides:
+# 1) test execution report
+# 2) valgrind/memcheck report
+# 3) raw coverage data (.gcda-files)
+sonar_runtests:
+ -valgrind --xml=yes --xml-file=$(BUILD_DIR)/valgrind-report.xml $(BUILD_DIR)/test_component1 --gtest_output=xml:$(BUILD_DIR)/xunit-report.xml
+
+# Collect the coverage data and convert it to cobertura-format
+sonar_coverage:
+ gcovr -x -r . > $(BUILD_DIR)/gcovr-report.xml
+
+# Parse collected data and feed it into sonar
+sonar_sonar:
+ sonar-scanner -X
diff --git a/cxx-sensors/src/samples/SampleProject2/Readme b/cxx-sensors/src/samples/SampleProject2/Readme
new file mode 100644
index 0000000000..150596329c
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/Readme
@@ -0,0 +1,39 @@
+################################################################################
+### WHAT IS THIS ###
+################################################################################
+
+This is a sample project demonstrating how to integrate sonar with
+your code base 'by hand'.
+
+It uses nothing but make for building and has a simple structure
+consisting of following 'subsystems':
+
+ - cli (=command line interface)
+ - lib (=library)
+ - tests (=unit tests)
+
+The tests-subdir also contains a stripped down version of gtest and
+also demostrates how to integrate this wonderfull unit test framework
+with your code.
+
+It assumes following software to be installed:
+- gcc
+- make
+- java, sonar-scanner
+- cppcheck
+- valgrind
+- Python, gcovr.py
+- vera++, perl, vera++Report2checkstyleReport.perl
+
+See the the Cxx-Plugin Wiki for some details on dependencies:
+https://github.com/SonarOpenCommunity/sonar-cxx/wiki
+
+
+################################################################################
+### USAGE ###
+################################################################################
+
+1) build the project with 'make'
+2) analyse the project with 'make sonar'
+
+cleanup with 'make clean'
diff --git a/cxx-sensors/src/samples/SampleProject2/sonar-project.properties b/cxx-sensors/src/samples/SampleProject2/sonar-project.properties
new file mode 100644
index 0000000000..eb4c9e0c92
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/sonar-project.properties
@@ -0,0 +1,25 @@
+# required metadata
+sonar.projectKey=CxxPlugin:Sample
+sonar.projectName=Sample
+sonar.projectVersion=0.0.1
+sonar.language=c++
+
+# path to source directories (required)
+sonar.sources=src
+sonar.tests=tests/unittests
+
+# path to the build artifact
+sonar.artifact.path=build/app
+
+# paths to the reports
+sonar.cxx.cppcheck.reportPath=build/cppcheck-report.xml
+sonar.cxx.pclint.reportPath=build/pclint-report.xml
+sonar.cxx.coverage.reportPath=build/gcovr-report*.xml
+sonar.cxx.coverage.itReportPath=build/gcovr-report*.xml
+sonar.cxx.coverage.overallReportPath=build/gcovr-report*.xml
+sonar.cxx.valgrind.reportPath=build/valgrind-report.xml
+sonar.cxx.vera.reportPath=build/vera++-report.xml
+sonar.cxx.rats.reportPath=build/rats-report.xml
+sonar.cxx.xunit.reportPath=build/xunit-report.xml
+
+sonar.cxx.includeDirectories=/usr/include/c++/4.8,/usr/include/i386-linux-gnu/c++/4.8,/usr/include,/usr/include/c++/4.8/tr1,/usr/include/linux,src
diff --git a/cxx-sensors/src/samples/SampleProject2/src/Makefile b/cxx-sensors/src/samples/SampleProject2/src/Makefile
new file mode 100644
index 0000000000..067e6cf4c9
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/src/Makefile
@@ -0,0 +1,7 @@
+all:
+ @$(MAKE) -C lib
+ @$(MAKE) -C cli
+
+clean:
+ @$(MAKE) clean -C lib
+ @$(MAKE) clean -C cli
diff --git a/cxx-sensors/src/samples/SampleProject2/src/cli/.gitignore b/cxx-sensors/src/samples/SampleProject2/src/cli/.gitignore
new file mode 100644
index 0000000000..ee7fff6c17
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/src/cli/.gitignore
@@ -0,0 +1,2 @@
+*.gc*
+*.o
diff --git a/cxx-sensors/src/samples/SampleProject2/src/cli/Makefile b/cxx-sensors/src/samples/SampleProject2/src/cli/Makefile
new file mode 100644
index 0000000000..e32cb87640
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/src/cli/Makefile
@@ -0,0 +1,11 @@
+CPPFLAGS = -I..
+
+OBJECTS = main.o
+$(BUILD_DIR)/app: $(OBJECTS)
+ $(LD) $(LDFLAGS) $(OBJECTS) $(BUILD_DIR)/libcomponents.a -o $@
+
+%.o : %.cc
+ $(CC) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
+
+clean:
+ rm -f *.o *.gc*
diff --git a/cxx-sensors/src/samples/SampleProject2/src/cli/main.cc b/cxx-sensors/src/samples/SampleProject2/src/cli/main.cc
new file mode 100644
index 0000000000..24414a8313
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/src/cli/main.cc
@@ -0,0 +1,8 @@
+#include
+#include
+
+int main(int argc, char* argv[])
+{
+ std::cout << "Here is main" << std::endl;
+ return Bar().foo();
+}
diff --git a/cxx-sensors/src/samples/SampleProject2/src/lib/.gitignore b/cxx-sensors/src/samples/SampleProject2/src/lib/.gitignore
new file mode 100644
index 0000000000..59d5f361bf
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/src/lib/.gitignore
@@ -0,0 +1,3 @@
+*.gc*
+*.o
+
diff --git a/cxx-sensors/src/samples/SampleProject2/src/lib/Makefile b/cxx-sensors/src/samples/SampleProject2/src/lib/Makefile
new file mode 100644
index 0000000000..87d3ed96de
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/src/lib/Makefile
@@ -0,0 +1,9 @@
+OBJECTS = component1.o
+$(BUILD_DIR)/libcomponents.a: $(OBJECTS)
+ $(AR) -r $@ $(OBJECTS)
+
+%.o : %.cc
+ $(CXX) -c $(CXXFLAGS) $< -o $@
+
+clean:
+ rm -f *.o *.gc*
diff --git a/cxx-sensors/src/samples/SampleProject2/src/lib/component1.cc b/cxx-sensors/src/samples/SampleProject2/src/lib/component1.cc
new file mode 100644
index 0000000000..19bb5e038a
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/src/lib/component1.cc
@@ -0,0 +1,52 @@
+#include
+
+#include \
+ "component1.hh"
+
+/**
+ * Does something
+ *
+ * @return: an int indicating something
+ */
+int Bar::foo(){
+ // single line comment
+
+ /*
+ * multi-line comment
+ */
+ int \
+ x; //unused variable
+
+ return 111;
+}
+
+
+void Bar::do_valgrind_errors(){
+ ///// lets provoke some valgrind errors /////
+
+ // Memory leak (definitely lost)
+ new float();
+
+ // Condition depends on undefined value
+ int a;
+ if(a) std::cout << "fired!!!" << std::endl;
+
+ // Invalid read
+ int* ip = new int(0);
+ delete ip;
+ int i = *ip;
+
+ // Invalid write
+ ip = new int(0);
+ delete ip;
+ *ip = 1;
+
+ // Invalid free
+ ip = new int(0);
+ delete ip;
+ delete ip;
+
+ // Mismatched free() / delete / delete []
+ ip = new int(0);
+ delete [] ip;
+}
diff --git a/cxx-sensors/src/samples/SampleProject2/src/lib/component1.hh b/cxx-sensors/src/samples/SampleProject2/src/lib/component1.hh
new file mode 100644
index 0000000000..de73f1a274
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/src/lib/component1.hh
@@ -0,0 +1,9 @@
+#ifndef COMPONENT1_HH
+#define COMPONENT1_HH
+
+class Bar {
+public:
+ int foo();
+ void do_valgrind_errors();
+};
+#endif
diff --git a/cxx-sensors/src/samples/SampleProject2/src/lib/component2.cc b/cxx-sensors/src/samples/SampleProject2/src/lib/component2.cc
new file mode 100644
index 0000000000..9c4eed1095
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/src/lib/component2.cc
@@ -0,0 +1,51 @@
+#include
+
+#include "component1.hh"
+
+/**
+ * Does something
+ *
+ * @return: an int indicating something
+ */
+int Bar::foo(){
+ // single line comment
+
+ /*
+ * multi-line comment
+ */
+ int \
+ x; //unused variable
+
+ return 111;
+}
+
+
+void Bar::do_valgrind_errors(){
+ ///// lets provoke some valgrind errors /////
+
+ // Memory leak (definitely lost)
+ new float();
+
+ // Condition depends on undefined value
+ int a;
+ if(a) std::cout << "fired!!!" << std::endl;
+
+ // Invalid read
+ int* ip = new int(0);
+ delete ip;
+ int i = *ip;
+
+ // Invalid write
+ ip = new int(0);
+ delete ip;
+ *ip = 1;
+
+ // Invalid free
+ ip = new int(0);
+ delete ip;
+ delete ip;
+
+ // Mismatched free() / delete / delete []
+ ip = new int(0);
+ delete [] ip;
+}
diff --git a/cxx-sensors/src/samples/SampleProject2/tests/.gitignore b/cxx-sensors/src/samples/SampleProject2/tests/.gitignore
new file mode 100644
index 0000000000..d3bf727c85
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/tests/.gitignore
@@ -0,0 +1,2 @@
+*.[oa]
+
diff --git a/cxx-sensors/src/samples/SampleProject2/tests/Makefile b/cxx-sensors/src/samples/SampleProject2/tests/Makefile
new file mode 100644
index 0000000000..51f03620f5
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/tests/Makefile
@@ -0,0 +1,17 @@
+# Root directory of google test framework
+GTEST_DIR = gtest-1.6.0
+
+CPPFLAGS = -I$(GTEST_DIR)/include -I$(GTEST_DIR)
+CXXFLAGS = -g
+
+all: libgtest.a
+ @$(MAKE) -C unittests
+
+libgtest.a:
+ $(CC) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_DIR)/src/gtest-all.cc -o gtest-all.o
+ $(CC) $(CPPFLAGS) $(CXXFLAGS) -c $(GTEST_DIR)/src/gtest_main.cc -o gtest_main.o
+ $(AR) -r libgtest.a gtest-all.o gtest_main.o
+
+clean:
+ rm -f *.a *.o *.gc*
+ @$(MAKE) clean -C unittests
diff --git a/cxx-sensors/src/samples/SampleProject2/tests/gtest-1.6.0/include/gtest/gtest-death-test.h b/cxx-sensors/src/samples/SampleProject2/tests/gtest-1.6.0/include/gtest/gtest-death-test.h
new file mode 100644
index 0000000000..a27883f0a4
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/tests/gtest-1.6.0/include/gtest/gtest-death-test.h
@@ -0,0 +1,283 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// The Google C++ Testing Framework (Google Test)
+//
+// This header file defines the public API for death tests. It is
+// #included by gtest.h so a user doesn't need to include this
+// directly.
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
+#define GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
+
+#include "gtest/internal/gtest-death-test-internal.h"
+
+namespace testing {
+
+// This flag controls the style of death tests. Valid values are "threadsafe",
+// meaning that the death test child process will re-execute the test binary
+// from the start, running only a single death test, or "fast",
+// meaning that the child process will execute the test logic immediately
+// after forking.
+GTEST_DECLARE_string_(death_test_style);
+
+#if GTEST_HAS_DEATH_TEST
+
+// The following macros are useful for writing death tests.
+
+// Here's what happens when an ASSERT_DEATH* or EXPECT_DEATH* is
+// executed:
+//
+// 1. It generates a warning if there is more than one active
+// thread. This is because it's safe to fork() or clone() only
+// when there is a single thread.
+//
+// 2. The parent process clone()s a sub-process and runs the death
+// test in it; the sub-process exits with code 0 at the end of the
+// death test, if it hasn't exited already.
+//
+// 3. The parent process waits for the sub-process to terminate.
+//
+// 4. The parent process checks the exit code and error message of
+// the sub-process.
+//
+// Examples:
+//
+// ASSERT_DEATH(server.SendMessage(56, "Hello"), "Invalid port number");
+// for (int i = 0; i < 5; i++) {
+// EXPECT_DEATH(server.ProcessRequest(i),
+// "Invalid request .* in ProcessRequest()")
+// << "Failed to die on request " << i);
+// }
+//
+// ASSERT_EXIT(server.ExitNow(), ::testing::ExitedWithCode(0), "Exiting");
+//
+// bool KilledBySIGHUP(int exit_code) {
+// return WIFSIGNALED(exit_code) && WTERMSIG(exit_code) == SIGHUP;
+// }
+//
+// ASSERT_EXIT(client.HangUpServer(), KilledBySIGHUP, "Hanging up!");
+//
+// On the regular expressions used in death tests:
+//
+// On POSIX-compliant systems (*nix), we use the library,
+// which uses the POSIX extended regex syntax.
+//
+// On other platforms (e.g. Windows), we only support a simple regex
+// syntax implemented as part of Google Test. This limited
+// implementation should be enough most of the time when writing
+// death tests; though it lacks many features you can find in PCRE
+// or POSIX extended regex syntax. For example, we don't support
+// union ("x|y"), grouping ("(xy)"), brackets ("[xy]"), and
+// repetition count ("x{5,7}"), among others.
+//
+// Below is the syntax that we do support. We chose it to be a
+// subset of both PCRE and POSIX extended regex, so it's easy to
+// learn wherever you come from. In the following: 'A' denotes a
+// literal character, period (.), or a single \\ escape sequence;
+// 'x' and 'y' denote regular expressions; 'm' and 'n' are for
+// natural numbers.
+//
+// c matches any literal character c
+// \\d matches any decimal digit
+// \\D matches any character that's not a decimal digit
+// \\f matches \f
+// \\n matches \n
+// \\r matches \r
+// \\s matches any ASCII whitespace, including \n
+// \\S matches any character that's not a whitespace
+// \\t matches \t
+// \\v matches \v
+// \\w matches any letter, _, or decimal digit
+// \\W matches any character that \\w doesn't match
+// \\c matches any literal character c, which must be a punctuation
+// . matches any single character except \n
+// A? matches 0 or 1 occurrences of A
+// A* matches 0 or many occurrences of A
+// A+ matches 1 or many occurrences of A
+// ^ matches the beginning of a string (not that of each line)
+// $ matches the end of a string (not that of each line)
+// xy matches x followed by y
+//
+// If you accidentally use PCRE or POSIX extended regex features
+// not implemented by us, you will get a run-time failure. In that
+// case, please try to rewrite your regular expression within the
+// above syntax.
+//
+// This implementation is *not* meant to be as highly tuned or robust
+// as a compiled regex library, but should perform well enough for a
+// death test, which already incurs significant overhead by launching
+// a child process.
+//
+// Known caveats:
+//
+// A "threadsafe" style death test obtains the path to the test
+// program from argv[0] and re-executes it in the sub-process. For
+// simplicity, the current implementation doesn't search the PATH
+// when launching the sub-process. This means that the user must
+// invoke the test program via a path that contains at least one
+// path separator (e.g. path/to/foo_test and
+// /absolute/path/to/bar_test are fine, but foo_test is not). This
+// is rarely a problem as people usually don't put the test binary
+// directory in PATH.
+//
+// TODO(wan@google.com): make thread-safe death tests search the PATH.
+
+// Asserts that a given statement causes the program to exit, with an
+// integer exit status that satisfies predicate, and emitting error output
+// that matches regex.
+# define ASSERT_EXIT(statement, predicate, regex) \
+ GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_FATAL_FAILURE_)
+
+// Like ASSERT_EXIT, but continues on to successive tests in the
+// test case, if any:
+# define EXPECT_EXIT(statement, predicate, regex) \
+ GTEST_DEATH_TEST_(statement, predicate, regex, GTEST_NONFATAL_FAILURE_)
+
+// Asserts that a given statement causes the program to exit, either by
+// explicitly exiting with a nonzero exit code or being killed by a
+// signal, and emitting error output that matches regex.
+# define ASSERT_DEATH(statement, regex) \
+ ASSERT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
+
+// Like ASSERT_DEATH, but continues on to successive tests in the
+// test case, if any:
+# define EXPECT_DEATH(statement, regex) \
+ EXPECT_EXIT(statement, ::testing::internal::ExitedUnsuccessfully, regex)
+
+// Two predicate classes that can be used in {ASSERT,EXPECT}_EXIT*:
+
+// Tests that an exit code describes a normal exit with a given exit code.
+class GTEST_API_ ExitedWithCode {
+ public:
+ explicit ExitedWithCode(int exit_code);
+ bool operator()(int exit_status) const;
+ private:
+ // No implementation - assignment is unsupported.
+ void operator=(const ExitedWithCode& other);
+
+ const int exit_code_;
+};
+
+# if !GTEST_OS_WINDOWS
+// Tests that an exit code describes an exit due to termination by a
+// given signal.
+class GTEST_API_ KilledBySignal {
+ public:
+ explicit KilledBySignal(int signum);
+ bool operator()(int exit_status) const;
+ private:
+ const int signum_;
+};
+# endif // !GTEST_OS_WINDOWS
+
+// EXPECT_DEBUG_DEATH asserts that the given statements die in debug mode.
+// The death testing framework causes this to have interesting semantics,
+// since the sideeffects of the call are only visible in opt mode, and not
+// in debug mode.
+//
+// In practice, this can be used to test functions that utilize the
+// LOG(DFATAL) macro using the following style:
+//
+// int DieInDebugOr12(int* sideeffect) {
+// if (sideeffect) {
+// *sideeffect = 12;
+// }
+// LOG(DFATAL) << "death";
+// return 12;
+// }
+//
+// TEST(TestCase, TestDieOr12WorksInDgbAndOpt) {
+// int sideeffect = 0;
+// // Only asserts in dbg.
+// EXPECT_DEBUG_DEATH(DieInDebugOr12(&sideeffect), "death");
+//
+// #ifdef NDEBUG
+// // opt-mode has sideeffect visible.
+// EXPECT_EQ(12, sideeffect);
+// #else
+// // dbg-mode no visible sideeffect.
+// EXPECT_EQ(0, sideeffect);
+// #endif
+// }
+//
+// This will assert that DieInDebugReturn12InOpt() crashes in debug
+// mode, usually due to a DCHECK or LOG(DFATAL), but returns the
+// appropriate fallback value (12 in this case) in opt mode. If you
+// need to test that a function has appropriate side-effects in opt
+// mode, include assertions against the side-effects. A general
+// pattern for this is:
+//
+// EXPECT_DEBUG_DEATH({
+// // Side-effects here will have an effect after this statement in
+// // opt mode, but none in debug mode.
+// EXPECT_EQ(12, DieInDebugOr12(&sideeffect));
+// }, "death");
+//
+# ifdef NDEBUG
+
+# define EXPECT_DEBUG_DEATH(statement, regex) \
+ do { statement; } while (::testing::internal::AlwaysFalse())
+
+# define ASSERT_DEBUG_DEATH(statement, regex) \
+ do { statement; } while (::testing::internal::AlwaysFalse())
+
+# else
+
+# define EXPECT_DEBUG_DEATH(statement, regex) \
+ EXPECT_DEATH(statement, regex)
+
+# define ASSERT_DEBUG_DEATH(statement, regex) \
+ ASSERT_DEATH(statement, regex)
+
+# endif // NDEBUG for EXPECT_DEBUG_DEATH
+#endif // GTEST_HAS_DEATH_TEST
+
+// EXPECT_DEATH_IF_SUPPORTED(statement, regex) and
+// ASSERT_DEATH_IF_SUPPORTED(statement, regex) expand to real death tests if
+// death tests are supported; otherwise they just issue a warning. This is
+// useful when you are combining death test assertions with normal test
+// assertions in one test.
+#if GTEST_HAS_DEATH_TEST
+# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
+ EXPECT_DEATH(statement, regex)
+# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
+ ASSERT_DEATH(statement, regex)
+#else
+# define EXPECT_DEATH_IF_SUPPORTED(statement, regex) \
+ GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, )
+# define ASSERT_DEATH_IF_SUPPORTED(statement, regex) \
+ GTEST_UNSUPPORTED_DEATH_TEST_(statement, regex, return)
+#endif
+
+} // namespace testing
+
+#endif // GTEST_INCLUDE_GTEST_GTEST_DEATH_TEST_H_
diff --git a/cxx-sensors/src/samples/SampleProject2/tests/gtest-1.6.0/include/gtest/gtest-message.h b/cxx-sensors/src/samples/SampleProject2/tests/gtest-1.6.0/include/gtest/gtest-message.h
new file mode 100644
index 0000000000..9b7142f320
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/tests/gtest-1.6.0/include/gtest/gtest-message.h
@@ -0,0 +1,230 @@
+// Copyright 2005, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Author: wan@google.com (Zhanyong Wan)
+//
+// The Google C++ Testing Framework (Google Test)
+//
+// This header file defines the Message class.
+//
+// IMPORTANT NOTE: Due to limitation of the C++ language, we have to
+// leave some internal implementation details in this header file.
+// They are clearly marked by comments like this:
+//
+// // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+//
+// Such code is NOT meant to be used by a user directly, and is subject
+// to CHANGE WITHOUT NOTICE. Therefore DO NOT DEPEND ON IT in a user
+// program!
+
+#ifndef GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
+#define GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
+
+#include
+
+#include "gtest/internal/gtest-string.h"
+#include "gtest/internal/gtest-internal.h"
+
+namespace testing {
+
+// The Message class works like an ostream repeater.
+//
+// Typical usage:
+//
+// 1. You stream a bunch of values to a Message object.
+// It will remember the text in a stringstream.
+// 2. Then you stream the Message object to an ostream.
+// This causes the text in the Message to be streamed
+// to the ostream.
+//
+// For example;
+//
+// testing::Message foo;
+// foo << 1 << " != " << 2;
+// std::cout << foo;
+//
+// will print "1 != 2".
+//
+// Message is not intended to be inherited from. In particular, its
+// destructor is not virtual.
+//
+// Note that stringstream behaves differently in gcc and in MSVC. You
+// can stream a NULL char pointer to it in the former, but not in the
+// latter (it causes an access violation if you do). The Message
+// class hides this difference by treating a NULL char pointer as
+// "(null)".
+class GTEST_API_ Message {
+ private:
+ // The type of basic IO manipulators (endl, ends, and flush) for
+ // narrow streams.
+ typedef std::ostream& (*BasicNarrowIoManip)(std::ostream&);
+
+ public:
+ // Constructs an empty Message.
+ // We allocate the stringstream separately because otherwise each use of
+ // ASSERT/EXPECT in a procedure adds over 200 bytes to the procedure's
+ // stack frame leading to huge stack frames in some cases; gcc does not reuse
+ // the stack space.
+ Message() : ss_(new ::std::stringstream) {
+ // By default, we want there to be enough precision when printing
+ // a double to a Message.
+ *ss_ << std::setprecision(std::numeric_limits::digits10 + 2);
+ }
+
+ // Copy constructor.
+ Message(const Message& msg) : ss_(new ::std::stringstream) { // NOLINT
+ *ss_ << msg.GetString();
+ }
+
+ // Constructs a Message from a C-string.
+ explicit Message(const char* str) : ss_(new ::std::stringstream) {
+ *ss_ << str;
+ }
+
+#if GTEST_OS_SYMBIAN
+ // Streams a value (either a pointer or not) to this object.
+ template
+ inline Message& operator <<(const T& value) {
+ StreamHelper(typename internal::is_pointer::type(), value);
+ return *this;
+ }
+#else
+ // Streams a non-pointer value to this object.
+ template
+ inline Message& operator <<(const T& val) {
+ ::GTestStreamToHelper(ss_.get(), val);
+ return *this;
+ }
+
+ // Streams a pointer value to this object.
+ //
+ // This function is an overload of the previous one. When you
+ // stream a pointer to a Message, this definition will be used as it
+ // is more specialized. (The C++ Standard, section
+ // [temp.func.order].) If you stream a non-pointer, then the
+ // previous definition will be used.
+ //
+ // The reason for this overload is that streaming a NULL pointer to
+ // ostream is undefined behavior. Depending on the compiler, you
+ // may get "0", "(nil)", "(null)", or an access violation. To
+ // ensure consistent result across compilers, we always treat NULL
+ // as "(null)".
+ template
+ inline Message& operator <<(T* const& pointer) { // NOLINT
+ if (pointer == NULL) {
+ *ss_ << "(null)";
+ } else {
+ ::GTestStreamToHelper(ss_.get(), pointer);
+ }
+ return *this;
+ }
+#endif // GTEST_OS_SYMBIAN
+
+ // Since the basic IO manipulators are overloaded for both narrow
+ // and wide streams, we have to provide this specialized definition
+ // of operator <<, even though its body is the same as the
+ // templatized version above. Without this definition, streaming
+ // endl or other basic IO manipulators to Message will confuse the
+ // compiler.
+ Message& operator <<(BasicNarrowIoManip val) {
+ *ss_ << val;
+ return *this;
+ }
+
+ // Instead of 1/0, we want to see true/false for bool values.
+ Message& operator <<(bool b) {
+ return *this << (b ? "true" : "false");
+ }
+
+ // These two overloads allow streaming a wide C string to a Message
+ // using the UTF-8 encoding.
+ Message& operator <<(const wchar_t* wide_c_str) {
+ return *this << internal::String::ShowWideCString(wide_c_str);
+ }
+ Message& operator <<(wchar_t* wide_c_str) {
+ return *this << internal::String::ShowWideCString(wide_c_str);
+ }
+
+#if GTEST_HAS_STD_WSTRING
+ // Converts the given wide string to a narrow string using the UTF-8
+ // encoding, and streams the result to this Message object.
+ Message& operator <<(const ::std::wstring& wstr);
+#endif // GTEST_HAS_STD_WSTRING
+
+#if GTEST_HAS_GLOBAL_WSTRING
+ // Converts the given wide string to a narrow string using the UTF-8
+ // encoding, and streams the result to this Message object.
+ Message& operator <<(const ::wstring& wstr);
+#endif // GTEST_HAS_GLOBAL_WSTRING
+
+ // Gets the text streamed to this object so far as a String.
+ // Each '\0' character in the buffer is replaced with "\\0".
+ //
+ // INTERNAL IMPLEMENTATION - DO NOT USE IN A USER PROGRAM.
+ internal::String GetString() const {
+ return internal::StringStreamToString(ss_.get());
+ }
+
+ private:
+
+#if GTEST_OS_SYMBIAN
+ // These are needed as the Nokia Symbian Compiler cannot decide between
+ // const T& and const T* in a function template. The Nokia compiler _can_
+ // decide between class template specializations for T and T*, so a
+ // tr1::type_traits-like is_pointer works, and we can overload on that.
+ template
+ inline void StreamHelper(internal::true_type /*dummy*/, T* pointer) {
+ if (pointer == NULL) {
+ *ss_ << "(null)";
+ } else {
+ ::GTestStreamToHelper(ss_.get(), pointer);
+ }
+ }
+ template
+ inline void StreamHelper(internal::false_type /*dummy*/, const T& value) {
+ ::GTestStreamToHelper(ss_.get(), value);
+ }
+#endif // GTEST_OS_SYMBIAN
+
+ // We'll hold the text streamed to this object here.
+ const internal::scoped_ptr< ::std::stringstream> ss_;
+
+ // We declare (but don't implement) this to prevent the compiler
+ // from implementing the assignment operator.
+ void operator=(const Message&);
+};
+
+// Streams a Message to an ostream.
+inline std::ostream& operator <<(std::ostream& os, const Message& sb) {
+ return os << sb.GetString();
+}
+
+} // namespace testing
+
+#endif // GTEST_INCLUDE_GTEST_GTEST_MESSAGE_H_
diff --git a/cxx-sensors/src/samples/SampleProject2/tests/gtest-1.6.0/include/gtest/gtest-param-test.h b/cxx-sensors/src/samples/SampleProject2/tests/gtest-1.6.0/include/gtest/gtest-param-test.h
new file mode 100644
index 0000000000..6407cfd685
--- /dev/null
+++ b/cxx-sensors/src/samples/SampleProject2/tests/gtest-1.6.0/include/gtest/gtest-param-test.h
@@ -0,0 +1,1421 @@
+// This file was GENERATED by command:
+// pump.py gtest-param-test.h.pump
+// DO NOT EDIT BY HAND!!!
+
+// Copyright 2008, Google Inc.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following disclaimer
+// in the documentation and/or other materials provided with the
+// distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+//
+// Authors: vladl@google.com (Vlad Losev)
+//
+// Macros and functions for implementing parameterized tests
+// in Google C++ Testing Framework (Google Test)
+//
+// This file is generated by a SCRIPT. DO NOT EDIT BY HAND!
+//
+#ifndef GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
+#define GTEST_INCLUDE_GTEST_GTEST_PARAM_TEST_H_
+
+
+// Value-parameterized tests allow you to test your code with different
+// parameters without writing multiple copies of the same test.
+//
+// Here is how you use value-parameterized tests:
+
+#if 0
+
+// To write value-parameterized tests, first you should define a fixture
+// class. It is usually derived from testing::TestWithParam (see below for
+// another inheritance scheme that's sometimes useful in more complicated
+// class hierarchies), where the type of your parameter values.
+// TestWithParam is itself derived from testing::Test. T can be any
+// copyable type. If it's a raw pointer, you are responsible for managing the
+// lifespan of the pointed values.
+
+class FooTest : public ::testing::TestWithParam {
+ // You can implement all the usual class fixture members here.
+};
+
+// Then, use the TEST_P macro to define as many parameterized tests
+// for this fixture as you want. The _P suffix is for "parameterized"
+// or "pattern", whichever you prefer to think.
+
+TEST_P(FooTest, DoesBlah) {
+ // Inside a test, access the test parameter with the GetParam() method
+ // of the TestWithParam class:
+ EXPECT_TRUE(foo.Blah(GetParam()));
+ ...
+}
+
+TEST_P(FooTest, HasBlahBlah) {
+ ...
+}
+
+// Finally, you can use INSTANTIATE_TEST_CASE_P to instantiate the test
+// case with any set of parameters you want. Google Test defines a number
+// of functions for generating test parameters. They return what we call
+// (surprise!) parameter generators. Here is a summary of them, which
+// are all in the testing namespace:
+//
+//
+// Range(begin, end [, step]) - Yields values {begin, begin+step,
+// begin+step+step, ...}. The values do not
+// include end. step defaults to 1.
+// Values(v1, v2, ..., vN) - Yields values {v1, v2, ..., vN}.
+// ValuesIn(container) - Yields values from a C-style array, an STL
+// ValuesIn(begin,end) container, or an iterator range [begin, end).
+// Bool() - Yields sequence {false, true}.
+// Combine(g1, g2, ..., gN) - Yields all combinations (the Cartesian product
+// for the math savvy) of the values generated
+// by the N generators.
+//
+// For more details, see comments at the definitions of these functions below
+// in this file.
+//
+// The following statement will instantiate tests from the FooTest test case
+// each with parameter values "meeny", "miny", and "moe".
+
+INSTANTIATE_TEST_CASE_P(InstantiationName,
+ FooTest,
+ Values("meeny", "miny", "moe"));
+
+// To distinguish different instances of the pattern, (yes, you
+// can instantiate it more then once) the first argument to the
+// INSTANTIATE_TEST_CASE_P macro is a prefix that will be added to the
+// actual test case name. Remember to pick unique prefixes for different
+// instantiations. The tests from the instantiation above will have
+// these names:
+//
+// * InstantiationName/FooTest.DoesBlah/0 for "meeny"
+// * InstantiationName/FooTest.DoesBlah/1 for "miny"
+// * InstantiationName/FooTest.DoesBlah/2 for "moe"
+// * InstantiationName/FooTest.HasBlahBlah/0 for "meeny"
+// * InstantiationName/FooTest.HasBlahBlah/1 for "miny"
+// * InstantiationName/FooTest.HasBlahBlah/2 for "moe"
+//
+// You can use these names in --gtest_filter.
+//
+// This statement will instantiate all tests from FooTest again, each
+// with parameter values "cat" and "dog":
+
+const char* pets[] = {"cat", "dog"};
+INSTANTIATE_TEST_CASE_P(AnotherInstantiationName, FooTest, ValuesIn(pets));
+
+// The tests from the instantiation above will have these names:
+//
+// * AnotherInstantiationName/FooTest.DoesBlah/0 for "cat"
+// * AnotherInstantiationName/FooTest.DoesBlah/1 for "dog"
+// * AnotherInstantiationName/FooTest.HasBlahBlah/0 for "cat"
+// * AnotherInstantiationName/FooTest.HasBlahBlah/1 for "dog"
+//
+// Please note that INSTANTIATE_TEST_CASE_P will instantiate all tests
+// in the given test case, whether their definitions come before or
+// AFTER the INSTANTIATE_TEST_CASE_P statement.
+//
+// Please also note that generator expressions (including parameters to the
+// generators) are evaluated in InitGoogleTest(), after main() has started.
+// This allows the user on one hand, to adjust generator parameters in order
+// to dynamically determine a set of tests to run and on the other hand,
+// give the user a chance to inspect the generated tests with Google Test
+// reflection API before RUN_ALL_TESTS() is executed.
+//
+// You can see samples/sample7_unittest.cc and samples/sample8_unittest.cc
+// for more examples.
+//
+// In the future, we plan to publish the API for defining new parameter
+// generators. But for now this interface remains part of the internal
+// implementation and is subject to change.
+//
+//
+// A parameterized test fixture must be derived from testing::Test and from
+// testing::WithParamInterface, where T is the type of the parameter
+// values. Inheriting from TestWithParam satisfies that requirement because
+// TestWithParam inherits from both Test and WithParamInterface. In more
+// complicated hierarchies, however, it is occasionally useful to inherit
+// separately from Test and WithParamInterface. For example:
+
+class BaseTest : public ::testing::Test {
+ // You can inherit all the usual members for a non-parameterized test
+ // fixture here.
+};
+
+class DerivedTest : public BaseTest, public ::testing::WithParamInterface {
+ // The usual test fixture members go here too.
+};
+
+TEST_F(BaseTest, HasFoo) {
+ // This is an ordinary non-parameterized test.
+}
+
+TEST_P(DerivedTest, DoesBlah) {
+ // GetParam works just the same here as if you inherit from TestWithParam.
+ EXPECT_TRUE(foo.Blah(GetParam()));
+}
+
+#endif // 0
+
+#include "gtest/internal/gtest-port.h"
+
+#if !GTEST_OS_SYMBIAN
+# include
+#endif
+
+// scripts/fuse_gtest.py depends on gtest's own header being #included
+// *unconditionally*. Therefore these #includes cannot be moved
+// inside #if GTEST_HAS_PARAM_TEST.
+#include "gtest/internal/gtest-internal.h"
+#include "gtest/internal/gtest-param-util.h"
+#include "gtest/internal/gtest-param-util-generated.h"
+
+#if GTEST_HAS_PARAM_TEST
+
+namespace testing {
+
+// Functions producing parameter generators.
+//
+// Google Test uses these generators to produce parameters for value-
+// parameterized tests. When a parameterized test case is instantiated
+// with a particular generator, Google Test creates and runs tests
+// for each element in the sequence produced by the generator.
+//
+// In the following sample, tests from test case FooTest are instantiated
+// each three times with parameter values 3, 5, and 8:
+//
+// class FooTest : public TestWithParam { ... };
+//
+// TEST_P(FooTest, TestThis) {
+// }
+// TEST_P(FooTest, TestThat) {
+// }
+// INSTANTIATE_TEST_CASE_P(TestSequence, FooTest, Values(3, 5, 8));
+//
+
+// Range() returns generators providing sequences of values in a range.
+//
+// Synopsis:
+// Range(start, end)
+// - returns a generator producing a sequence of values {start, start+1,
+// start+2, ..., }.
+// Range(start, end, step)
+// - returns a generator producing a sequence of values {start, start+step,
+// start+step+step, ..., }.
+// Notes:
+// * The generated sequences never include end. For example, Range(1, 5)
+// returns a generator producing a sequence {1, 2, 3, 4}. Range(1, 9, 2)
+// returns a generator producing {1, 3, 5, 7}.
+// * start and end must have the same type. That type may be any integral or
+// floating-point type or a user defined type satisfying these conditions:
+// * It must be assignable (have operator=() defined).
+// * It must have operator+() (operator+(int-compatible type) for
+// two-operand version).
+// * It must have operator<() defined.
+// Elements in the resulting sequences will also have that type.
+// * Condition start < end must be satisfied in order for resulting sequences
+// to contain any elements.
+//
+template
+internal::ParamGenerator Range(T start, T end, IncrementT step) {
+ return internal::ParamGenerator(
+ new internal::RangeGenerator(start, end, step));
+}
+
+template
+internal::ParamGenerator Range(T start, T end) {
+ return Range(start, end, 1);
+}
+
+// ValuesIn() function allows generation of tests with parameters coming from
+// a container.
+//
+// Synopsis:
+// ValuesIn(const T (&array)[N])
+// - returns a generator producing sequences with elements from
+// a C-style array.
+// ValuesIn(const Container& container)
+// - returns a generator producing sequences with elements from
+// an STL-style container.
+// ValuesIn(Iterator begin, Iterator end)
+// - returns a generator producing sequences with elements from
+// a range [begin, end) defined by a pair of STL-style iterators. These
+// iterators can also be plain C pointers.
+//
+// Please note that ValuesIn copies the values from the containers
+// passed in and keeps them to generate tests in RUN_ALL_TESTS().
+//
+// Examples:
+//
+// This instantiates tests from test case StringTest
+// each with C-string values of "foo", "bar", and "baz":
+//
+// const char* strings[] = {"foo", "bar", "baz"};
+// INSTANTIATE_TEST_CASE_P(StringSequence, SrtingTest, ValuesIn(strings));
+//
+// This instantiates tests from test case StlStringTest
+// each with STL strings with values "a" and "b":
+//
+// ::std::vector< ::std::string> GetParameterStrings() {
+// ::std::vector< ::std::string> v;
+// v.push_back("a");
+// v.push_back("b");
+// return v;
+// }
+//
+// INSTANTIATE_TEST_CASE_P(CharSequence,
+// StlStringTest,
+// ValuesIn(GetParameterStrings()));
+//
+//
+// This will also instantiate tests from CharTest
+// each with parameter values 'a' and 'b':
+//
+// ::std::list GetParameterChars() {
+// ::std::list list;
+// list.push_back('a');
+// list.push_back('b');
+// return list;
+// }
+// ::std::list l = GetParameterChars();
+// INSTANTIATE_TEST_CASE_P(CharSequence2,
+// CharTest,
+// ValuesIn(l.begin(), l.end()));
+//
+template
+internal::ParamGenerator<
+ typename ::testing::internal::IteratorTraits::value_type>
+ValuesIn(ForwardIterator begin, ForwardIterator end) {
+ typedef typename ::testing::internal::IteratorTraits
+ ::value_type ParamType;
+ return internal::ParamGenerator(
+ new internal::ValuesInIteratorRangeGenerator(begin, end));
+}
+
+template
+internal::ParamGenerator ValuesIn(const T (&array)[N]) {
+ return ValuesIn(array, array + N);
+}
+
+template
+internal::ParamGenerator ValuesIn(
+ const Container& container) {
+ return ValuesIn(container.begin(), container.end());
+}
+
+// Values() allows generating tests from explicitly specified list of
+// parameters.
+//
+// Synopsis:
+// Values(T v1, T v2, ..., T vN)
+// - returns a generator producing sequences with elements v1, v2, ..., vN.
+//
+// For example, this instantiates tests from test case BarTest each
+// with values "one", "two", and "three":
+//
+// INSTANTIATE_TEST_CASE_P(NumSequence, BarTest, Values("one", "two", "three"));
+//
+// This instantiates tests from test case BazTest each with values 1, 2, 3.5.
+// The exact type of values will depend on the type of parameter in BazTest.
+//
+// INSTANTIATE_TEST_CASE_P(FloatingNumbers, BazTest, Values(1, 2, 3.5));
+//
+// Currently, Values() supports from 1 to 50 parameters.
+//
+template
+internal::ValueArray1 Values(T1 v1) {
+ return internal::ValueArray1(v1);
+}
+
+template
+internal::ValueArray2 Values(T1 v1, T2 v2) {
+ return internal::ValueArray2(v1, v2);
+}
+
+template
+internal::ValueArray3 Values(T1 v1, T2 v2, T3 v3) {
+ return internal::ValueArray3(v1, v2, v3);
+}
+
+template
+internal::ValueArray4 Values(T1 v1, T2 v2, T3 v3, T4 v4) {
+ return internal::ValueArray4(v1, v2, v3, v4);
+}
+
+template
+internal::ValueArray5 Values(T1 v1, T2 v2, T3 v3, T4 v4,
+ T5 v5) {
+ return internal::ValueArray5(v1, v2, v3, v4, v5);
+}
+
+template
+internal::ValueArray6 Values(T1 v1, T2 v2, T3 v3,
+ T4 v4, T5 v5, T6 v6) {
+ return internal::ValueArray6(v1, v2, v3, v4, v5, v6);
+}
+
+template
+internal::ValueArray7 Values(T1 v1, T2 v2, T3 v3,
+ T4 v4, T5 v5, T6 v6, T7 v7) {
+ return internal::ValueArray7(v1, v2, v3, v4, v5,
+ v6, v7);
+}
+
+template
+internal::ValueArray8 Values(T1 v1, T2 v2,
+ T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8) {
+ return internal::ValueArray8(v1, v2, v3, v4,
+ v5, v6, v7, v8);
+}
+
+template
+internal::ValueArray9 Values(T1 v1, T2 v2,
+ T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9) {
+ return internal::ValueArray9(v1, v2, v3,
+ v4, v5, v6, v7, v8, v9);
+}
+
+template
+internal::ValueArray10 Values(T1 v1,
+ T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10) {
+ return internal::ValueArray10(v1,
+ v2, v3, v4, v5, v6, v7, v8, v9, v10);
+}
+
+template
+internal::ValueArray11 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11) {
+ return internal::ValueArray11(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11);
+}
+
+template
+internal::ValueArray12 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12) {
+ return internal::ValueArray12(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12);
+}
+
+template
+internal::ValueArray13 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13) {
+ return internal::ValueArray13(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
+}
+
+template
+internal::ValueArray14 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13, T14 v14) {
+ return internal::ValueArray14(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
+ v14);
+}
+
+template
+internal::ValueArray15 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
+ T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15) {
+ return internal::ValueArray15(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
+ v13, v14, v15);
+}
+
+template
+internal::ValueArray16 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+ T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+ T16 v16) {
+ return internal::ValueArray16(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
+ v12, v13, v14, v15, v16);
+}
+
+template
+internal::ValueArray17 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+ T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+ T16 v16, T17 v17) {
+ return internal::ValueArray17(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
+ v11, v12, v13, v14, v15, v16, v17);
+}
+
+template
+internal::ValueArray18 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
+ T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+ T16 v16, T17 v17, T18 v18) {
+ return internal::ValueArray18(v1, v2, v3, v4, v5, v6, v7, v8, v9,
+ v10, v11, v12, v13, v14, v15, v16, v17, v18);
+}
+
+template
+internal::ValueArray19 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
+ T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
+ T15 v15, T16 v16, T17 v17, T18 v18, T19 v19) {
+ return internal::ValueArray19(v1, v2, v3, v4, v5, v6, v7, v8,
+ v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19);
+}
+
+template
+internal::ValueArray20 Values(T1 v1, T2 v2, T3 v3, T4 v4,
+ T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+ T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20) {
+ return internal::ValueArray20(v1, v2, v3, v4, v5, v6, v7,
+ v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20);
+}
+
+template
+internal::ValueArray21 Values(T1 v1, T2 v2, T3 v3, T4 v4,
+ T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+ T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21) {
+ return internal::ValueArray21(v1, v2, v3, v4, v5, v6,
+ v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21);
+}
+
+template
+internal::ValueArray22 Values(T1 v1, T2 v2, T3 v3,
+ T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+ T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+ T21 v21, T22 v22) {
+ return internal::ValueArray22(v1, v2, v3, v4,
+ v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+ v20, v21, v22);
+}
+
+template
+internal::ValueArray23 Values(T1 v1, T2 v2,
+ T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+ T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+ T21 v21, T22 v22, T23 v23) {
+ return internal::ValueArray23(v1, v2, v3,
+ v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+ v20, v21, v22, v23);
+}
+
+template
+internal::ValueArray24 Values(T1 v1, T2 v2,
+ T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+ T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+ T21 v21, T22 v22, T23 v23, T24 v24) {
+ return internal::ValueArray24(v1, v2,
+ v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
+ v19, v20, v21, v22, v23, v24);
+}
+
+template
+internal::ValueArray25 Values(T1 v1,
+ T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
+ T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
+ T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25) {
+ return internal::ValueArray25(v1,
+ v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
+ v18, v19, v20, v21, v22, v23, v24, v25);
+}
+
+template
+internal::ValueArray26 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+ T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+ T26 v26) {
+ return internal::ValueArray26(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
+ v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26);
+}
+
+template
+internal::ValueArray27 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+ T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+ T26 v26, T27 v27) {
+ return internal::ValueArray27(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
+ v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27);
+}
+
+template
+internal::ValueArray28 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+ T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+ T26 v26, T27 v27, T28 v28) {
+ return internal::ValueArray28(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
+ v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
+ v28);
+}
+
+template
+internal::ValueArray29 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+ T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+ T26 v26, T27 v27, T28 v28, T29 v29) {
+ return internal::ValueArray29(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
+ v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
+ v27, v28, v29);
+}
+
+template
+internal::ValueArray30 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
+ T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
+ T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
+ T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30) {
+ return internal::ValueArray30(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
+ v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
+ v26, v27, v28, v29, v30);
+}
+
+template
+internal::ValueArray31 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+ T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+ T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+ T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31) {
+ return internal::ValueArray31(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
+ v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
+ v25, v26, v27, v28, v29, v30, v31);
+}
+
+template
+internal::ValueArray32 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+ T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+ T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+ T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+ T32 v32) {
+ return internal::ValueArray32(v1, v2, v3, v4, v5, v6, v7, v8, v9,
+ v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
+ v24, v25, v26, v27, v28, v29, v30, v31, v32);
+}
+
+template
+internal::ValueArray33 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
+ T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+ T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+ T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+ T32 v32, T33 v33) {
+ return internal::ValueArray33(v1, v2, v3, v4, v5, v6, v7, v8,
+ v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
+ v24, v25, v26, v27, v28, v29, v30, v31, v32, v33);
+}
+
+template
+internal::ValueArray34 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
+ T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
+ T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
+ T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
+ T31 v31, T32 v32, T33 v33, T34 v34) {
+ return internal::ValueArray34(v1, v2, v3, v4, v5, v6, v7,
+ v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
+ v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34);
+}
+
+template
+internal::ValueArray35 Values(T1 v1, T2 v2, T3 v3, T4 v4,
+ T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+ T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
+ T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
+ T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35) {
+ return internal::ValueArray35(v1, v2, v3, v4, v5, v6,
+ v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
+ v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35);
+}
+
+template
+internal::ValueArray36 Values(T1 v1, T2 v2, T3 v3, T4 v4,
+ T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+ T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
+ T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
+ T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36) {
+ return internal::ValueArray36(v1, v2, v3, v4,
+ v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+ v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
+ v34, v35, v36);
+}
+
+template
+internal::ValueArray37 Values(T1 v1, T2 v2, T3 v3,
+ T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+ T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+ T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
+ T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
+ T37 v37) {
+ return internal::ValueArray37(v1, v2, v3,
+ v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+ v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
+ v34, v35, v36, v37);
+}
+
+template
+internal::ValueArray38 Values(T1 v1, T2 v2,
+ T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+ T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+ T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
+ T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
+ T37 v37, T38 v38) {
+ return internal::ValueArray38(v1, v2,
+ v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18,
+ v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32,
+ v33, v34, v35, v36, v37, v38);
+}
+
+template
+internal::ValueArray39 Values(T1 v1, T2 v2,
+ T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12,
+ T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20,
+ T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28,
+ T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36,
+ T37 v37, T38 v38, T39 v39) {
+ return internal::ValueArray39(v1,
+ v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17,
+ v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
+ v32, v33, v34, v35, v36, v37, v38, v39);
+}
+
+template
+internal::ValueArray40 Values(T1 v1,
+ T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11,
+ T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19,
+ T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27,
+ T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35,
+ T36 v36, T37 v37, T38 v38, T39 v39, T40 v40) {
+ return internal::ValueArray40(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
+ v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29,
+ v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40);
+}
+
+template
+internal::ValueArray41 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+ T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+ T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+ T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41) {
+ return internal::ValueArray41(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14,
+ v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28,
+ v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41);
+}
+
+template
+internal::ValueArray42 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+ T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+ T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+ T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+ T42 v42) {
+ return internal::ValueArray42(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13,
+ v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27,
+ v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40, v41,
+ v42);
+}
+
+template
+internal::ValueArray43 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+ T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+ T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+ T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+ T42 v42, T43 v43) {
+ return internal::ValueArray43(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12,
+ v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26,
+ v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39, v40,
+ v41, v42, v43);
+}
+
+template
+internal::ValueArray44 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8, T9 v9,
+ T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16, T17 v17,
+ T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24, T25 v25,
+ T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32, T33 v33,
+ T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40, T41 v41,
+ T42 v42, T43 v43, T44 v44) {
+ return internal::ValueArray44(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11,
+ v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24, v25,
+ v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38, v39,
+ v40, v41, v42, v43, v44);
+}
+
+template
+internal::ValueArray45 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7, T8 v8,
+ T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15, T16 v16,
+ T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23, T24 v24,
+ T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31, T32 v32,
+ T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39, T40 v40,
+ T41 v41, T42 v42, T43 v43, T44 v44, T45 v45) {
+ return internal::ValueArray45(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10,
+ v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23, v24,
+ v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37, v38,
+ v39, v40, v41, v42, v43, v44, v45);
+}
+
+template
+internal::ValueArray46 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+ T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+ T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+ T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+ T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
+ T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46) {
+ return internal::ValueArray46(v1, v2, v3, v4, v5, v6, v7, v8, v9,
+ v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
+ v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
+ v38, v39, v40, v41, v42, v43, v44, v45, v46);
+}
+
+template
+internal::ValueArray47 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6, T7 v7,
+ T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+ T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+ T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+ T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
+ T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47) {
+ return internal::ValueArray47(v1, v2, v3, v4, v5, v6, v7, v8,
+ v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22, v23,
+ v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36, v37,
+ v38, v39, v40, v41, v42, v43, v44, v45, v46, v47);
+}
+
+template
+internal::ValueArray48 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5, T6 v6,
+ T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14, T15 v15,
+ T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22, T23 v23,
+ T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30, T31 v31,
+ T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38, T39 v39,
+ T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46, T47 v47,
+ T48 v48) {
+ return internal::ValueArray48(v1, v2, v3, v4, v5, v6, v7,
+ v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21, v22,
+ v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35, v36,
+ v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48);
+}
+
+template
+internal::ValueArray49 Values(T1 v1, T2 v2, T3 v3, T4 v4, T5 v5,
+ T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13, T14 v14,
+ T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21, T22 v22,
+ T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29, T30 v30,
+ T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37, T38 v38,
+ T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45, T46 v46,
+ T47 v47, T48 v48, T49 v49) {
+ return internal::ValueArray49(v1, v2, v3, v4, v5, v6,
+ v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19, v20, v21,
+ v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33, v34, v35,
+ v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47, v48, v49);
+}
+
+template
+internal::ValueArray50 Values(T1 v1, T2 v2, T3 v3, T4 v4,
+ T5 v5, T6 v6, T7 v7, T8 v8, T9 v9, T10 v10, T11 v11, T12 v12, T13 v13,
+ T14 v14, T15 v15, T16 v16, T17 v17, T18 v18, T19 v19, T20 v20, T21 v21,
+ T22 v22, T23 v23, T24 v24, T25 v25, T26 v26, T27 v27, T28 v28, T29 v29,
+ T30 v30, T31 v31, T32 v32, T33 v33, T34 v34, T35 v35, T36 v36, T37 v37,
+ T38 v38, T39 v39, T40 v40, T41 v41, T42 v42, T43 v43, T44 v44, T45 v45,
+ T46 v46, T47 v47, T48 v48, T49 v49, T50 v50) {
+ return internal::ValueArray50(v1, v2, v3, v4,
+ v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19,
+ v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31, v32, v33,
+ v34, v35, v36, v37, v38, v39, v40, v41, v42, v43, v44, v45, v46, v47,
+ v48, v49, v50);
+}
+
+// Bool() allows generating tests with parameters in a set of (false, true).
+//
+// Synopsis:
+// Bool()
+// - returns a generator producing sequences with elements {false, true}.
+//
+// It is useful when testing code that depends on Boolean flags. Combinations
+// of multiple flags can be tested when several Bool()'s are combined using
+// Combine() function.
+//
+// In the following example all tests in the test case FlagDependentTest
+// will be instantiated twice with parameters false and true.
+//
+// class FlagDependentTest : public testing::TestWithParam {
+// virtual void SetUp() {
+// external_flag = GetParam();
+// }
+// }
+// INSTANTIATE_TEST_CASE_P(BoolSequence, FlagDependentTest, Bool());
+//
+inline internal::ParamGenerator Bool() {
+ return Values(false, true);
+}
+
+# if GTEST_HAS_COMBINE
+// Combine() allows the user to combine two or more sequences to produce
+// values of a Cartesian product of those sequences' elements.
+//
+// Synopsis:
+// Combine(gen1, gen2, ..., genN)
+// - returns a generator producing sequences with elements coming from
+// the Cartesian product of elements from the sequences generated by
+// gen1, gen2, ..., genN. The sequence elements will have a type of
+// tuple where T1, T2, ..., TN are the types
+// of elements from sequences produces by gen1, gen2, ..., genN.
+//
+// Combine can have up to 10 arguments. This number is currently limited
+// by the maximum number of elements in the tuple implementation used by Google
+// Test.
+//
+// Example:
+//
+// This will instantiate tests in test case AnimalTest each one with
+// the parameter values tuple("cat", BLACK), tuple("cat", WHITE),
+// tuple("dog", BLACK), and tuple("dog", WHITE):
+//
+// enum Color { BLACK, GRAY, WHITE };
+// class AnimalTest
+// : public testing::TestWithParam > {...};
+//
+// TEST_P(AnimalTest, AnimalLooksNice) {...}
+//
+// INSTANTIATE_TEST_CASE_P(AnimalVariations, AnimalTest,
+// Combine(Values("cat", "dog"),
+// Values(BLACK, WHITE)));
+//
+// This will instantiate tests in FlagDependentTest with all variations of two
+// Boolean flags:
+//
+// class FlagDependentTest
+// : public testing::TestWithParam