Skip to content

Commit

Permalink
make all sensors 'reportPath' properties multi-value
Browse files Browse the repository at this point in the history
1. fixes SonarOpenCommunity#1384

Literaly all sensors derived from `CxxReportSensor` as well as `CxxSquidSensor`
use use the method `CxxReportSensor::getReports()` in order to access the
reporth paths. This method expects the `*.reportPath` property to be
a multi-value one. So fix the property access

* use `getStringArray()` method for parsing
* mark corresponding properties as multi-value

2. fixes SonarOpenCommunity#1376

While working on (1) I've found out, that the property
`UnitTestConfiguration.NUNIT_TEST_RESULTS_PROPERTY_KEY` is not public
accessible. This contradicts to the SonarOpenCommunity#1376.

On the other hand, if there should be no soupport for NUnit,
either the property must be marked as deprecated or the NUnit support
has to be removed completely. Please review.
  • Loading branch information
ivangalkin committed Oct 8, 2018
1 parent 040a94a commit d5ae09d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ public static List<File> getReports(Configuration settings,
return reports;
}

String reportPathString = settings.get(genericReportKeyData).orElse("");
if (reportPathString.isEmpty()) {
String[] reportPathString = settings.getStringArray(genericReportKeyData);
if (reportPathString.length == 0) {
LOG.info("Undefined report path value for key '{}'", genericReportKeyData);
} else {
List<String> reportPaths = Arrays.asList(splitProperty(reportPathString));
List<String> reportPaths = Arrays.asList(reportPathString);

List<String> includes = normalizeReportPaths(moduleBaseDir, reportPaths);
if (LOG.isDebugEnabled()) {
Expand Down
14 changes: 14 additions & 0 deletions sonar-c-plugin/src/main/java/org/sonar/plugins/c/CPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ private static List<PropertyDefinition> generalProperties() {
+ USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(9)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxSquidSensor.REPORT_CHARSET_DEF)
Expand Down Expand Up @@ -206,6 +207,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(1)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCppCheckRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -222,6 +224,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(3)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxValgrindRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -238,6 +241,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(5)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxPCLintSensor.REPORT_PATH_KEY)
Expand All @@ -246,6 +250,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ "projects root." + USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(5)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxPCLintRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -262,6 +267,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ "relative to projects root." + USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(7)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxRatsRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -278,6 +284,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(9)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxVeraxxRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -296,6 +303,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ "here</a> for details.")
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(11)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxOtherRepository.RULES_KEY)
Expand All @@ -314,6 +322,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ USE_ANT_STYLE_WILDCARDS_2)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(13)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxClangTidySensor.REPORT_CHARSET_DEF)
Expand All @@ -338,6 +347,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ USE_ANT_STYLE_WILDCARDS_2)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(16)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxClangSARuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -359,6 +369,7 @@ private static List<PropertyDefinition> compilerWarningsProperties() {
+ USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(1)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCompilerVcSensor.REPORT_CHARSET_DEF)
Expand Down Expand Up @@ -393,6 +404,7 @@ private static List<PropertyDefinition> compilerWarningsProperties() {
+ USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(5)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCompilerGccSensor.REPORT_CHARSET_DEF)
Expand Down Expand Up @@ -434,6 +446,7 @@ private static List<PropertyDefinition> testingAndCoverageProperties() {
+ "here</a> for supported formats." + USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(1)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxXunitSensor.REPORT_PATH_KEY)
Expand All @@ -443,6 +456,7 @@ private static List<PropertyDefinition> testingAndCoverageProperties() {
+ "here</a> for supported formats." + USE_ANT_STYLE_WILDCARDS_1)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(6)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxXunitSensor.XSLT_URL_KEY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ private static List<PropertyDefinition> generalProperties() {
+ USE_ANT_STYLE_WILDCARDS)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(9)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxSquidSensor.REPORT_CHARSET_DEF)
Expand Down Expand Up @@ -215,6 +216,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(1)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCppCheckRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -231,6 +233,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ USE_ANT_STYLE_WILDCARDS)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(3)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxValgrindRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -247,6 +250,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ USE_ANT_STYLE_WILDCARDS)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(5)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxPCLintSensor.REPORT_PATH_KEY)
Expand All @@ -255,6 +259,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ " root." + USE_ANT_STYLE_WILDCARDS)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(5)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxPCLintRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -271,6 +276,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ " relative to projects root." + USE_ANT_STYLE_WILDCARDS)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(7)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxRatsRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -287,6 +293,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ USE_ANT_STYLE_WILDCARDS)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(9)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxVeraxxRuleRepository.CUSTOM_RULES_KEY)
Expand All @@ -304,6 +311,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ "/wiki/Extending-the-code-analysis'>here</a> for details.")
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(11)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxOtherRepository.RULES_KEY)
Expand All @@ -321,6 +329,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ "<a href='https://ant.apache.org/manual/dirtasks.html'>Ant-style wildcards</a> are at your service.")
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(13)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxClangTidySensor.REPORT_CHARSET_DEF)
Expand All @@ -345,6 +354,7 @@ private static List<PropertyDefinition> codeAnalysisProperties() {
+ "<a href='https://ant.apache.org/manual/dirtasks.html'>Ant-style wildcards</a> are at your service.")
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(16)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxClangSARuleRepository.CUSTOM_RULES_KEY)
Expand Down Expand Up @@ -384,6 +394,7 @@ private static List<PropertyDefinition> compilerWarningsProperties() {
+ USE_ANT_STYLE_WILDCARDS)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(1)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCompilerVcSensor.REPORT_CHARSET_DEF)
Expand Down Expand Up @@ -418,6 +429,7 @@ private static List<PropertyDefinition> compilerWarningsProperties() {
+ USE_ANT_STYLE_WILDCARDS)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(5)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCompilerGccSensor.REPORT_CHARSET_DEF)
Expand Down Expand Up @@ -455,14 +467,14 @@ private static List<PropertyDefinition> testingAndCoverageProperties() {

properties.add(
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxCoverageSensor.REPORT_PATH_KEY)
.multiValues(true)
.name("Unit test coverage report(s)")
.description("List of paths to reports containing unit test coverage data, relative to projects root."
+ " The values are separated by commas."
+ " See <a href='https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Get-code-coverage-metrics'>"
+ "here</a> for supported formats.")
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(1)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxXunitSensor.REPORT_PATH_KEY)
Expand All @@ -472,6 +484,7 @@ private static List<PropertyDefinition> testingAndCoverageProperties() {
+ "here</a> for supported formats." + USE_ANT_STYLE_WILDCARDS)
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.multiValues(true)
.index(2)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX + CxxXunitSensor.XSLT_URL_KEY)
Expand Down Expand Up @@ -500,6 +513,15 @@ private static List<PropertyDefinition> testingAndCoverageProperties() {
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.index(5)
.build(),
PropertyDefinition.builder(LANG_PROP_PREFIX
+ UnitTestConfiguration.NUNIT_TEST_RESULTS_PROPERTY_KEY)
.multiValues(true)
.name("NUnit Test Reports Paths")
.description("Example: \"TestResult.xml\", \"TestResult1.xml,TestResult2.xml\" or \"C:/TestResult.xml\"")
.subCategory(subcateg)
.onQualifiers(Qualifiers.PROJECT, Qualifiers.MODULE)
.index(6)
.build()
);
return properties.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ public void testGetExtensions() throws Exception {
Plugin.Context context = new Plugin.Context(runtime);
CxxPlugin plugin = new CxxPlugin();
plugin.define(context);
assertThat(context.getExtensions()).hasSize(81);
assertThat(context.getExtensions()).hasSize(82);
}
}

0 comments on commit d5ae09d

Please sign in to comment.