aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-scanner-engine/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-scanner-engine/src/main/java')
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LogOutput.java1
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java17
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/events/BatchStepHandler.java1
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/index/DefaultIndex.java8
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoader.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/ScanTaskObserver.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/AbstractPhaseExecutor.java10
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisherStep.java1
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RuleFinderCompatibility.java5
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java8
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ConsoleReport.java12
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReport.java10
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReportBuilder.java3
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ReportSummary.java2
-rw-r--r--sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/Reporter.java1
15 files changed, 35 insertions, 52 deletions
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LogOutput.java b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LogOutput.java
index b69c405d931..8bfa4301e1d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LogOutput.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/batch/bootstrapper/LogOutput.java
@@ -23,6 +23,7 @@ package org.sonar.batch.bootstrapper;
* Allow to redirect batch logs to a custom output. By defaults logs are written to System.out
* @since 5.2
*/
+@FunctionalInterface
public interface LogOutput {
void log(String formattedMessage, Level level);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
index 285a25d6848..c3ca55c4507 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/cpd/CpdExecutor.java
@@ -22,6 +22,14 @@ package org.sonar.scanner.cpd;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.config.Settings;
import org.sonar.api.utils.log.Logger;
@@ -39,15 +47,6 @@ import org.sonar.scanner.protocol.output.ScannerReport.Duplicate;
import org.sonar.scanner.protocol.output.ScannerReport.Duplication;
import org.sonar.scanner.report.ReportPublisher;
import org.sonar.scanner.util.ProgressReport;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
import static com.google.common.collect.FluentIterable.from;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/events/BatchStepHandler.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/events/BatchStepHandler.java
index c2c437d7369..f2c6b472229 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/events/BatchStepHandler.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/events/BatchStepHandler.java
@@ -24,6 +24,7 @@ import org.sonar.api.batch.events.EventHandler;
/**
* @since 3.7
*/
+@FunctionalInterface
public interface BatchStepHandler extends EventHandler {
/**
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/index/DefaultIndex.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/index/DefaultIndex.java
index ffad84c3e68..4cb9f5b48d8 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/index/DefaultIndex.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/index/DefaultIndex.java
@@ -278,14 +278,6 @@ public class DefaultIndex {
return bucket;
}
- public boolean isExcluded(@Nullable Resource reference) {
- return false;
- }
-
- public boolean isIndexed(@Nullable Resource reference, boolean acceptExcluded) {
- return getBucket(reference) != null;
- }
-
private Bucket getBucket(@Nullable Resource reference) {
if (reference == null) {
return null;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoader.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoader.java
index a45a601cdb0..0e8df6952db 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoader.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoader.java
@@ -19,13 +19,12 @@
*/
package org.sonar.scanner.issue.ignore.scanner;
+import java.nio.charset.Charset;
import org.sonar.api.batch.fs.FileSystem;
import org.sonar.api.batch.fs.InputFile;
import org.sonar.api.batch.fs.internal.DefaultInputFile;
-import org.sonar.api.resources.Project;
import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer;
import org.sonar.scanner.issue.ignore.pattern.IssueInclusionPatternInitializer;
-import java.nio.charset.Charset;
public final class IssueExclusionsLoader {
@@ -43,7 +42,7 @@ public final class IssueExclusionsLoader {
this.fileSystem = fileSystem;
}
- public boolean shouldExecuteOnProject(Project project) {
+ public boolean shouldExecute() {
return inclusionPatternInitializer.hasConfiguredPatterns()
|| exclusionPatternInitializer.hasConfiguredPatterns();
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/ScanTaskObserver.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/ScanTaskObserver.java
index 02881a66caa..9b1ab15ade1 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/ScanTaskObserver.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/mediumtest/ScanTaskObserver.java
@@ -19,12 +19,13 @@
*/
package org.sonar.scanner.mediumtest;
+import org.sonar.api.ExtensionPoint;
import org.sonar.api.batch.ScannerSide;
import org.sonar.scanner.scan.ProjectScanContainer;
-import org.sonar.api.ExtensionPoint;
@ScannerSide
@ExtensionPoint
+@FunctionalInterface
public interface ScanTaskObserver {
void scanTaskCompleted(ProjectScanContainer container);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/AbstractPhaseExecutor.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/AbstractPhaseExecutor.java
index 3174c667682..ec6ca476708 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/AbstractPhaseExecutor.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/phases/AbstractPhaseExecutor.java
@@ -88,10 +88,12 @@ public abstract class AbstractPhaseExecutor {
protected abstract void executeOnRoot();
private void initIssueExclusions() {
- String stepName = "Init issue exclusions";
- eventBus.fireEvent(new BatchStepEvent(stepName, true));
- issueExclusionsLoader.execute();
- eventBus.fireEvent(new BatchStepEvent(stepName, false));
+ if (issueExclusionsLoader.shouldExecute()) {
+ String stepName = "Init issue exclusions";
+ eventBus.fireEvent(new BatchStepEvent(stepName, true));
+ issueExclusionsLoader.execute();
+ eventBus.fireEvent(new BatchStepEvent(stepName, false));
+ }
}
private void indexFs() {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisherStep.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisherStep.java
index a1f7221ce6d..374f3cf060d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisherStep.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/report/ReportPublisherStep.java
@@ -24,6 +24,7 @@ import org.sonar.scanner.protocol.output.ScannerReportWriter;
/**
* Adds a sub-part of data to output report
*/
+@FunctionalInterface
public interface ReportPublisherStep {
void publish(ScannerReportWriter writer);
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RuleFinderCompatibility.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RuleFinderCompatibility.java
index a1689c5dc6e..cee346fc94c 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RuleFinderCompatibility.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/rule/RuleFinderCompatibility.java
@@ -34,11 +34,6 @@ import org.sonar.api.rules.RuleQuery;
import static org.sonar.core.util.stream.Collectors.toList;
-/**
- * FIXME Waiting for the list of all server rules on batch side this is implemented by redirecting on ActiveRules. This is not correct
- * since there is a difference between a rule that doesn't exists and a rule that is not activated in project quality profile.
- *
- */
public class RuleFinderCompatibility implements RuleFinder {
private final Rules rules;
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
index d89d897c9e2..0a2148c762d 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/ModuleScanContainer.java
@@ -33,7 +33,6 @@ import org.sonar.scanner.DefaultFileLinesContextFactory;
import org.sonar.scanner.DefaultProjectTree;
import org.sonar.scanner.bootstrap.BatchExtensionDictionnary;
import org.sonar.scanner.bootstrap.ExtensionInstaller;
-import org.sonar.scanner.bootstrap.ExtensionMatcher;
import org.sonar.scanner.bootstrap.ExtensionUtils;
import org.sonar.scanner.deprecated.DeprecatedSensorContext;
import org.sonar.scanner.deprecated.perspectives.BatchPerspectives;
@@ -174,12 +173,7 @@ public class ModuleScanContainer extends ComponentContainer {
private void addExtensions() {
ExtensionInstaller installer = getComponentByType(ExtensionInstaller.class);
- installer.install(this, new ExtensionMatcher() {
- @Override
- public boolean accept(Object extension) {
- return ExtensionUtils.isScannerSide(extension) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT);
- }
- });
+ installer.install(this, e -> ExtensionUtils.isScannerSide(e) && ExtensionUtils.isInstantiationStrategy(e, InstantiationStrategy.PER_PROJECT));
}
@Override
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ConsoleReport.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ConsoleReport.java
index 6add4c065b6..d4ddff8b2e7 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ConsoleReport.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ConsoleReport.java
@@ -126,17 +126,17 @@ public class ConsoleReport implements Reporter {
int newIssues = r.totalNewIssues;
if (newIssues > 0) {
sb.append(StringUtils.leftPad("+" + newIssues, LEFT_PAD)).append(" issue" + (newIssues > 1 ? "s" : "")).append("\n\n");
- printNewIssues(sb, r.newBlockerIssues, Severity.BLOCKER, "blocker");
- printNewIssues(sb, r.newCriticalIssues, Severity.CRITICAL, "critical");
- printNewIssues(sb, r.newMajorIssues, Severity.MAJOR, "major");
- printNewIssues(sb, r.newMinorIssues, Severity.MINOR, "minor");
- printNewIssues(sb, r.newInfoIssues, Severity.INFO, "info");
+ printNewIssues(sb, r.newBlockerIssues, "blocker");
+ printNewIssues(sb, r.newCriticalIssues, "critical");
+ printNewIssues(sb, r.newMajorIssues, "major");
+ printNewIssues(sb, r.newMinorIssues, "minor");
+ printNewIssues(sb, r.newInfoIssues, "info");
} else {
sb.append(" No new issue").append("\n");
}
}
- private static void printNewIssues(StringBuilder sb, int issueCount, String severity, String severityLabel) {
+ private static void printNewIssues(StringBuilder sb, int issueCount, String severityLabel) {
if (issueCount > 0) {
sb.append(StringUtils.leftPad("+" + issueCount, LEFT_PAD)).append(" ").append(severityLabel).append("\n");
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReport.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReport.java
index 33c3bf7de97..470c2d0339e 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReport.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReport.java
@@ -20,12 +20,10 @@
package org.sonar.scanner.scan.report;
import com.google.common.collect.Maps;
-
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
-
import org.sonar.api.batch.rule.Rule;
import org.sonar.api.rules.RulePriority;
import org.sonar.scanner.index.BatchComponent;
@@ -83,13 +81,13 @@ public class IssuesReport {
public void addIssueOnResource(BatchComponent resource, TrackedIssue issue, Rule rule, RulePriority severity) {
addResource(resource);
getSummary().addIssue(issue, rule, severity);
- resourceReportsByResource.get(resource).addIssue(issue, rule, RulePriority.valueOf(issue.severity()));
+ resourceReportsByResource.get(resource).addIssue(issue, rule, severity);
}
- public void addResolvedIssueOnResource(BatchComponent resource, TrackedIssue issue, Rule rule, RulePriority severity) {
+ public void addResolvedIssueOnResource(BatchComponent resource, Rule rule, RulePriority severity) {
addResource(resource);
- getSummary().addResolvedIssue(issue, rule, severity);
- resourceReportsByResource.get(resource).addResolvedIssue(rule, RulePriority.valueOf(issue.severity()));
+ getSummary().addResolvedIssue(rule, severity);
+ resourceReportsByResource.get(resource).addResolvedIssue(rule, severity);
}
private void addResource(BatchComponent resource) {
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReportBuilder.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReportBuilder.java
index d598f36c145..d69ba0f70f3 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReportBuilder.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/IssuesReportBuilder.java
@@ -20,7 +20,6 @@
package org.sonar.scanner.scan.report;
import javax.annotation.CheckForNull;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.batch.ScannerSide;
@@ -75,7 +74,7 @@ public class IssuesReportBuilder {
continue;
}
if (issue.resolution() != null) {
- issuesReport.addResolvedIssueOnResource(resource, issue, rule, severity);
+ issuesReport.addResolvedIssueOnResource(resource, rule, severity);
} else {
issuesReport.addIssueOnResource(resource, issue, rule, severity);
}
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ReportSummary.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ReportSummary.java
index 7fb0554de0b..d915acd6005 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ReportSummary.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/ReportSummary.java
@@ -63,7 +63,7 @@ public class ReportSummary {
return totalByRuleKey;
}
- public void addResolvedIssue(TrackedIssue issue, Rule rule, RulePriority severity) {
+ public void addResolvedIssue(Rule rule, RulePriority severity) {
ReportRuleKey reportRuleKey = new ReportRuleKey(rule, severity);
initMaps(reportRuleKey);
total.incrementResolvedIssuesCount();
diff --git a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/Reporter.java b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/Reporter.java
index 3d1f9e2f3da..6c462a64de9 100644
--- a/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/Reporter.java
+++ b/sonar-scanner-engine/src/main/java/org/sonar/scanner/scan/report/Reporter.java
@@ -22,6 +22,7 @@ package org.sonar.scanner.scan.report;
import org.sonar.api.batch.ScannerSide;
@ScannerSide
+@FunctionalInterface
public interface Reporter {
void execute();