Skip to content

Commit

Permalink
Merge pull request #1869 from Facthunder/feature-refactor-reportPath
Browse files Browse the repository at this point in the history
Refactor reportPath to reportPaths as requested by #1219
  • Loading branch information
guwirth authored May 25, 2020
2 parents 3e518a8 + e07ff89 commit c97a1f1
Show file tree
Hide file tree
Showing 49 changed files with 213 additions and 200 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
*/
public class CxxClangSASensor extends CxxIssuesReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.clangsa.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.clangsa.reportPaths";

private static final Logger LOG = Loggers.get(CxxClangSASensor.class);

Expand Down Expand Up @@ -75,7 +75,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX Clang Static Analyzer report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepository(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

private void addFlowToIssue(final NSDictionary diagnostic, final NSObject[] sourceFiles, final CxxReportIssue issue) {
Expand Down Expand Up @@ -136,7 +136,7 @@ protected void processReport(File report) throws javax.xml.stream.XMLStreamExcep
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
public class CxxClangTidySensor extends CxxIssuesReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.clangtidy.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.clangtidy.reportPaths";
public static final String REPORT_CHARSET_DEF = "sonar.cxx.clangtidy.charset";
public static final String DEFAULT_CHARSET_DEF = StandardCharsets.UTF_8.name();
private static final Logger LOG = Loggers.get(CxxClangTidySensor.class);
Expand Down Expand Up @@ -79,7 +79,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX Clang-Tidy report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepository(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

@Override
Expand Down Expand Up @@ -148,7 +148,7 @@ protected void processReport(File report) {
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class CxxCompilerGccSensor extends CxxCompilerSensor {

public static final String KEY = "GCC";
public static final String REPORT_PATH_KEY = "sonar.cxx.gcc.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.gcc.reportPaths";
public static final String REPORT_REGEX_DEF = "sonar.cxx.gcc.regex";
public static final String REPORT_CHARSET_DEF = "sonar.cxx.gcc.charset";
public static final String DEFAULT_CHARSET_DEF = StandardCharsets.UTF_8.name();
Expand Down Expand Up @@ -82,7 +82,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX GCC compiler report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepositories(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

@Override
Expand Down Expand Up @@ -112,7 +112,7 @@ protected String alignId(String id) {
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class CxxCompilerVcSensor extends CxxCompilerSensor {

public static final String KEY = "Visual C++";
public static final String REPORT_PATH_KEY = "sonar.cxx.vc.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.vc.reportPaths";
public static final String REPORT_REGEX_DEF = "sonar.cxx.vc.regex";
public static final String REPORT_CHARSET_DEF = "sonar.cxx.vc.charset";
public static final String DEFAULT_CHARSET_DEF = StandardCharsets.UTF_8.name();
Expand Down Expand Up @@ -78,7 +78,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX Visual Studio compiler report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepositories(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

@Override
Expand All @@ -97,7 +97,7 @@ protected String getRegex() {
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
public class CxxCoverageSensor extends CxxReportSensor {

// Configuration properties before SQ 6.2
public static final String REPORT_PATH_KEY = "sonar.cxx.coverage.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.coverage.reportPaths";

private static final Logger LOG = Loggers.get(CxxCoverageSensor.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*/
public class CxxCppCheckSensor extends CxxIssuesReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.cppcheck.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.cppcheck.reportPaths";
private static final Logger LOG = Loggers.get(CxxCppCheckSensor.class);

public static List<PropertyDefinition> properties() {
Expand All @@ -65,7 +65,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX Cppcheck report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepository(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

@Override
Expand All @@ -80,7 +80,7 @@ protected void processReport(File report) throws javax.xml.stream.XMLStreamExcep
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*/
public class CxxDrMemorySensor extends CxxIssuesReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.drmemory.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.drmemory.reportPaths";
private static final Logger LOG = Loggers.get(CxxDrMemorySensor.class);
private static final String DEFAULT_CHARSET_DEF = StandardCharsets.UTF_8.name();

Expand Down Expand Up @@ -75,7 +75,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX Dr. Memory report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepository(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

private boolean frameIsInProject(Location frame) {
Expand Down Expand Up @@ -125,7 +125,7 @@ protected void processReport(File report) {
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX Infer report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepository(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

@Override
Expand All @@ -77,7 +77,7 @@ protected void processReport(File report) {
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*/
public class CxxOtherSensor extends CxxIssuesReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.other.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.other.reportPaths";
public static final String RULES_KEY = "sonar.cxx.other.rules";

private static final Logger LOG = Loggers.get(CxxOtherSensor.class);
Expand Down Expand Up @@ -83,7 +83,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX external analyser report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepository(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

@Override
Expand All @@ -110,7 +110,7 @@ public void processReport(File report) throws XMLStreamException, IOException, U
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*/
public class CxxPCLintSensor extends CxxIssuesReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.pclint.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.pclint.reportPaths";
public static final Pattern MISRA_RULE_PATTERN = Pattern.compile(
// Rule nn.nn -or- Rule nn-nn-nn
"Rule\\x20(\\d{1,2}.\\d{1,2}|\\d{1,2}-\\d{1,2}-\\d{1,2})(,|\\])");
Expand Down Expand Up @@ -85,7 +85,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX PC-lint report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepository(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

@Override
Expand Down Expand Up @@ -237,7 +237,7 @@ private String mapMisraRulesToUniqueSonarRules(String msg, boolean isMisra2012)
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/
public class CxxRatsSensor extends CxxIssuesReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.rats.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.rats.reportPaths";

private static final Logger LOG = Loggers.get(CxxRatsSensor.class);
private static final String MISSING_RATS_TYPE = "fixed size global buffer";
Expand Down Expand Up @@ -74,7 +74,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX RATS report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepository(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

@Override
Expand Down Expand Up @@ -112,7 +112,7 @@ protected void processReport(File report) throws org.jdom2.JDOMException, java.i
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*/
public class CxxXunitSensor extends CxxReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.xunit.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.xunit.reportPaths";
private static final Logger LOG = Loggers.get(CxxXunitSensor.class);

public static List<PropertyDefinition> properties() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ protected CxxIssuesReportSensor() {
public void executeImpl() {
try {
LOG.info("Searching reports by relative path with basedir '{}' and search prop '{}'",
context.fileSystem().baseDir(), getReportPathKey());
List<File> reports = getReports(getReportPathKey());
context.fileSystem().baseDir(), getReportPathsKey());
List<File> reports = getReports(getReportPathsKey());

for (var report : reports) {
LOG.info("Processing report '{}'", report);
Expand Down Expand Up @@ -195,7 +195,7 @@ private void addFlow(NewIssue newIssue, CxxReportIssue issue) {

protected abstract void processReport(File report) throws Exception;

protected abstract String getReportPathKey();
protected abstract String getReportPathsKey();

protected abstract String getRuleRepositoryKey();
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public abstract class CxxReportSensor implements ProjectSensor {
protected CxxReportSensor() {
}

public List<File> getReports(String reportPathKey) {
return CxxUtils.getFiles(context, reportPathKey);
public List<File> getReports(String reportPathsKey) {
return CxxUtils.getFiles(context, reportPathsKey);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,19 @@ public static String resolveAntPath(final String baseDir, @Nullable final String
}

/**
* Use the given context object in order to get a list of Ant patterns referenced by key reportPathKey. Apply
* Use the given context object in order to get a list of Ant patterns referenced by key reportPathsKey. Apply
* context.fileSystem().baseDir() in order to make relative Ant patterns to absolute ones. Resolve Ant patterns and
* returns the list of existing files.
*
* @param context sensor context
* @param reportPathKey configuration key for files (CSV list of Ant patterns)
* @param reportPathsKey configuration key for files (CSV list of Ant patterns)
*
* @return List<File> matching file list
*/
public static List<File> getFiles(SensorContext context, String reportPathKey) {
String[] reportPaths = context.config().getStringArray(reportPathKey);
public static List<File> getFiles(SensorContext context, String reportPathsKey) {
String[] reportPaths = context.config().getStringArray(reportPathsKey);
if (reportPaths == null || reportPaths.length == 0) {
LOG.info("Undefined report path value for key '{}'", reportPathKey);
LOG.info("Undefined report path value for key '{}'", reportPathsKey);
return Collections.emptyList();
}

Expand All @@ -133,7 +133,7 @@ public static List<File> getFiles(SensorContext context, String reportPathKey) {
String[] existingReportPaths = directoryScanner.getIncludedFiles();

if (existingReportPaths.length == 0) {
LOG.warn("Property '{}': cannot find any files matching the Ant pattern(s) '{}'", reportPathKey,
LOG.warn("Property '{}': cannot find any files matching the Ant pattern(s) '{}'", reportPathsKey,
String.join(", ", normalizedReportPaths));
return Collections.emptyList();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
*/
public class CxxValgrindSensor extends CxxIssuesReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.valgrind.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.valgrind.reportPaths";

private static final Logger LOG = Loggers.get(CxxValgrindSensor.class);

Expand Down Expand Up @@ -108,7 +108,7 @@ protected void processReport(File report) throws javax.xml.stream.XMLStreamExcep
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*/
public class CxxVeraxxSensor extends CxxIssuesReportSensor {

public static final String REPORT_PATH_KEY = "sonar.cxx.vera.reportPath";
public static final String REPORT_PATH_KEY = "sonar.cxx.vera.reportPaths";
private static final Logger LOG = Loggers.get(CxxVeraxxSensor.class);

public static List<PropertyDefinition> properties() {
Expand All @@ -64,7 +64,7 @@ public void describe(SensorDescriptor descriptor) {
.name("CXX Vera++ report import")
.onlyOnLanguage("cxx")
.createIssuesForRuleRepository(getRuleRepositoryKey())
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathKey()));
.onlyWhenConfiguration(conf -> conf.hasKey(getReportPathsKey()));
}

@Override
Expand Down Expand Up @@ -108,7 +108,7 @@ protected void processReport(File report)
}

@Override
protected String getReportPathKey() {
protected String getReportPathsKey() {
return REPORT_PATH_KEY;
}

Expand Down
Loading

0 comments on commit c97a1f1

Please sign in to comment.