From 31f83fbcab419d16c5911583784d6cf780f8c6cf Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 13 Jul 2016 17:12:46 +0200 Subject: [PATCH] Fix some quality flaws --- .../main/java/org/sonar/api/SonarRuntime.java | 4 ++-- .../api/batch/fs/internal/DefaultInputFile.java | 1 + .../internal/DefaultHighlighting.java | 2 -- .../org/sonar/batch/bootstrapper/LogOutput.java | 1 + .../java/org/sonar/scanner/cpd/CpdExecutor.java | 17 ++++++++--------- .../sonar/scanner/events/BatchStepHandler.java | 1 + .../org/sonar/scanner/index/DefaultIndex.java | 8 -------- .../ignore/scanner/IssueExclusionsLoader.java | 5 ++--- .../scanner/mediumtest/ScanTaskObserver.java | 3 ++- .../scanner/phases/AbstractPhaseExecutor.java | 10 ++++++---- .../scanner/report/ReportPublisherStep.java | 1 + .../scanner/rule/RuleFinderCompatibility.java | 5 ----- .../sonar/scanner/scan/ModuleScanContainer.java | 8 +------- .../scanner/scan/report/ConsoleReport.java | 12 ++++++------ .../sonar/scanner/scan/report/IssuesReport.java | 10 ++++------ .../scan/report/IssuesReportBuilder.java | 3 +-- .../scanner/scan/report/ReportSummary.java | 2 +- .../org/sonar/scanner/scan/report/Reporter.java | 1 + .../sonar/scanner/index/DefaultIndexTest.java | 12 +----------- .../scanner/IssueExclusionsLoaderTest.java | 14 ++++++-------- 20 files changed, 45 insertions(+), 75 deletions(-) diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/SonarRuntime.java b/sonar-plugin-api/src/main/java/org/sonar/api/SonarRuntime.java index 0760fb77244..86b37e9e54c 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/SonarRuntime.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/SonarRuntime.java @@ -22,7 +22,7 @@ package org.sonar.api; import com.google.common.base.Preconditions; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; -import org.sonar.api.batch.BatchSide; +import org.sonar.api.batch.ScannerSide; import org.sonar.api.batch.sensor.Sensor; import org.sonar.api.ce.ComputeEngineSide; import org.sonar.api.server.ServerSide; @@ -121,7 +121,7 @@ import static java.util.Objects.requireNonNull; * * @since 6.0 */ -@BatchSide +@ScannerSide @ServerSide @ComputeEngineSide @SonarLintSide diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java index 031fa6de245..a3d4de28654 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java @@ -120,6 +120,7 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile return moduleKey; } + @Override public Charset charset() { return charset; } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java index 34df663e54a..6ccc541dad3 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/sensor/highlighting/internal/DefaultHighlighting.java @@ -79,8 +79,6 @@ public class DefaultHighlighting extends DefaultStorable implements NewHighlight checkInputFileNotNull(); TextRange newRange; try { - // TODO remove when SONAR-7664 is implemented - Preconditions.checkArgument(startOffset < endOffset, "start offset should be strictly before end offset"); newRange = inputFile.newRange(startOffset, endOffset); } catch (Exception e) { throw new IllegalArgumentException("Unable to highlight file " + inputFile, e); 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(); diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/index/DefaultIndexTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/index/DefaultIndexTest.java index 33462983e62..9d52431cd4f 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/index/DefaultIndexTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/index/DefaultIndexTest.java @@ -34,10 +34,8 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Resource; import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; -import org.sonar.scanner.FakeJava; import org.sonar.scanner.DefaultProjectTree; -import org.sonar.scanner.index.BatchComponentCache; -import org.sonar.scanner.index.DefaultIndex; +import org.sonar.scanner.FakeJava; import org.sonar.scanner.scan.measure.MeasureCache; import org.sonar.scanner.sensor.DefaultSensorStorage; @@ -93,8 +91,6 @@ public class DefaultIndexTest { Directory reference = Directory.create("src/org/foo"); assertThat(index.getResource(reference).getName()).isEqualTo("src/org/foo"); - assertThat(index.isIndexed(reference, true)).isTrue(); - assertThat(index.isExcluded(reference)).isFalse(); assertThat(index.getChildren(reference)).hasSize(1); assertThat(index.getParent(reference)).isInstanceOf(Project.class); } @@ -110,8 +106,6 @@ public class DefaultIndexTest { File fileRef = File.create("src/org/foo/Bar.java", null, false); assertThat(index.getResource(fileRef).getKey()).isEqualTo("src/org/foo/Bar.java"); assertThat(index.getResource(fileRef).getLanguage().getKey()).isEqualTo("java"); - assertThat(index.isIndexed(fileRef, true)).isTrue(); - assertThat(index.isExcluded(fileRef)).isFalse(); assertThat(index.getChildren(fileRef)).isEmpty(); assertThat(index.getParent(fileRef)).isInstanceOf(Directory.class); } @@ -137,9 +131,6 @@ public class DefaultIndexTest { assertThat(index.index(file, directory)).isFalse(); File fileRef = File.create("src/org/foo/Bar.java", null, false); - assertThat(index.isIndexed(directory, true)).isFalse(); - assertThat(index.isIndexed(fileRef, true)).isFalse(); - assertThat(index.isExcluded(fileRef)).isFalse(); assertThat(index.getChildren(fileRef)).isEmpty(); assertThat(index.getParent(fileRef)).isNull(); } @@ -149,7 +140,6 @@ public class DefaultIndexTest { Resource dir = Directory.create("src/org/foo"); index.addMeasure(dir, new Measure("ncloc").setValue(50.0)); - assertThat(index.isIndexed(dir, true)).isFalse(); assertThat(index.getMeasures(dir, MeasuresFilters.metric("ncloc"))).isNull(); } diff --git a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoaderTest.java b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoaderTest.java index 0ba0ee0178d..f0b9ef844f5 100644 --- a/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoaderTest.java +++ b/sonar-scanner-engine/src/test/java/org/sonar/scanner/issue/ignore/scanner/IssueExclusionsLoaderTest.java @@ -19,6 +19,8 @@ */ package org.sonar.scanner.issue.ignore.scanner; +import java.io.File; +import java.io.IOException; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -32,10 +34,6 @@ import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.scanner.issue.ignore.pattern.IssueExclusionPatternInitializer; import org.sonar.scanner.issue.ignore.pattern.IssueInclusionPatternInitializer; import org.sonar.scanner.issue.ignore.pattern.PatternMatcher; -import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader; -import org.sonar.scanner.issue.ignore.scanner.IssueExclusionsRegexpScanner; -import java.io.File; -import java.io.IOException; import static java.nio.charset.StandardCharsets.UTF_8; import static org.assertj.core.api.Assertions.assertThat; @@ -85,19 +83,19 @@ public class IssueExclusionsLoaderTest { public void shouldExecute() { when(exclusionPatternInitializer.hasConfiguredPatterns()).thenReturn(true); when(inclusionPatternInitializer.hasConfiguredPatterns()).thenReturn(true); - assertThat(scanner.shouldExecuteOnProject(null)).isTrue(); + assertThat(scanner.shouldExecute()).isTrue(); when(exclusionPatternInitializer.hasConfiguredPatterns()).thenReturn(true); when(inclusionPatternInitializer.hasConfiguredPatterns()).thenReturn(false); - assertThat(scanner.shouldExecuteOnProject(null)).isTrue(); + assertThat(scanner.shouldExecute()).isTrue(); when(exclusionPatternInitializer.hasConfiguredPatterns()).thenReturn(false); when(inclusionPatternInitializer.hasConfiguredPatterns()).thenReturn(true); - assertThat(scanner.shouldExecuteOnProject(null)).isTrue(); + assertThat(scanner.shouldExecute()).isTrue(); when(exclusionPatternInitializer.hasConfiguredPatterns()).thenReturn(false); when(inclusionPatternInitializer.hasConfiguredPatterns()).thenReturn(false); - assertThat(scanner.shouldExecuteOnProject(null)).isFalse(); + assertThat(scanner.shouldExecute()).isFalse(); } -- 2.39.5