diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2014-02-17 11:51:16 +0100 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2014-02-17 12:22:58 +0100 |
commit | 5debbecc152bf7aff83601e6a39d4247c8f522df (patch) | |
tree | afb3f59af452eb218afbba86d196b5095a3298dd /plugins | |
parent | d07420e0fb678bd8561ded6ed62057029c3eae62 (diff) | |
download | sonarqube-5debbecc152bf7aff83601e6a39d4247c8f522df.tar.gz sonarqube-5debbecc152bf7aff83601e6a39d4247c8f522df.zip |
Ensure that JavaSquidSensor is executed after exclusions initialization
Diffstat (limited to 'plugins')
5 files changed, 22 insertions, 19 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/IgnoreIssuesPlugin.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/IgnoreIssuesPlugin.java index 248c13853ff..c39060a912c 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/IgnoreIssuesPlugin.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/IgnoreIssuesPlugin.java @@ -23,8 +23,8 @@ package org.sonar.plugins.core.issue.ignore; import com.google.common.collect.ImmutableList; import org.sonar.plugins.core.issue.ignore.pattern.ExclusionPatternInitializer; import org.sonar.plugins.core.issue.ignore.pattern.InclusionPatternInitializer; -import org.sonar.plugins.core.issue.ignore.scanner.RegexpScanner; -import org.sonar.plugins.core.issue.ignore.scanner.SourceScanner; +import org.sonar.plugins.core.issue.ignore.scanner.IgnoreIssuesRegexpScanner; +import org.sonar.plugins.core.issue.ignore.scanner.IgnoreIssuesSourceScanner; import java.util.List; @@ -41,8 +41,8 @@ public final class IgnoreIssuesPlugin { extensions.add( InclusionPatternInitializer.class, ExclusionPatternInitializer.class, - RegexpScanner.class, - SourceScanner.class, + IgnoreIssuesRegexpScanner.class, + IgnoreIssuesSourceScanner.class, EnforceIssuesFilter.class, IgnoreIssuesFilter.class); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/RegexpScanner.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/IgnoreIssuesRegexpScanner.java index b479000d013..d6fa2d26fa6 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/RegexpScanner.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/IgnoreIssuesRegexpScanner.java @@ -37,9 +37,9 @@ import java.nio.charset.Charset; import java.util.List; import java.util.Set; -public class RegexpScanner implements BatchExtension { +public class IgnoreIssuesRegexpScanner implements BatchExtension { - private static final Logger LOG = LoggerFactory.getLogger(RegexpScanner.class); + private static final Logger LOG = LoggerFactory.getLogger(IgnoreIssuesRegexpScanner.class); private ExclusionPatternInitializer exclusionPatternInitializer; private List<java.util.regex.Pattern> allFilePatterns; @@ -51,7 +51,7 @@ public class RegexpScanner implements BatchExtension { private List<LineExclusion> lineExclusions; private LineExclusion currentLineExclusion; - public RegexpScanner(ExclusionPatternInitializer patternsInitializer) { + public IgnoreIssuesRegexpScanner(ExclusionPatternInitializer patternsInitializer) { this.exclusionPatternInitializer = patternsInitializer; lineExclusions = Lists.newArrayList(); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/SourceScanner.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/IgnoreIssuesSourceScanner.java index 23a61888fee..f88696d7128 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/SourceScanner.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/scanner/IgnoreIssuesSourceScanner.java @@ -20,30 +20,33 @@ package org.sonar.plugins.core.issue.ignore.scanner; -import org.sonar.api.scan.filesystem.InputFile; - +import org.sonar.api.batch.DependedUpon; import org.sonar.api.batch.Phase; import org.sonar.api.batch.Sensor; import org.sonar.api.batch.SensorContext; import org.sonar.api.resources.Project; import org.sonar.api.scan.filesystem.FileQuery; +import org.sonar.api.scan.filesystem.InputFile; import org.sonar.api.scan.filesystem.internal.DefaultInputFile; import org.sonar.api.utils.SonarException; import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; +import org.sonar.java.api.JavaUtils; import org.sonar.plugins.core.issue.ignore.pattern.ExclusionPatternInitializer; import org.sonar.plugins.core.issue.ignore.pattern.InclusionPatternInitializer; import java.nio.charset.Charset; @Phase(name = Phase.Name.PRE) -public final class SourceScanner implements Sensor { +// Issue Exclusions must be computed before JavaSquidSensor is executed and creates issues +@DependedUpon(value = JavaUtils.BARRIER_BEFORE_SQUID) +public final class IgnoreIssuesSourceScanner implements Sensor { - private final RegexpScanner regexpScanner; + private final IgnoreIssuesRegexpScanner regexpScanner; private final ExclusionPatternInitializer exclusionPatternInitializer; private final InclusionPatternInitializer inclusionPatternInitializer; private final DefaultModuleFileSystem fileSystem; - public SourceScanner(RegexpScanner regexpScanner, ExclusionPatternInitializer exclusionPatternInitializer, InclusionPatternInitializer inclusionPatternInitializer, + public IgnoreIssuesSourceScanner(IgnoreIssuesRegexpScanner regexpScanner, ExclusionPatternInitializer exclusionPatternInitializer, InclusionPatternInitializer inclusionPatternInitializer, DefaultModuleFileSystem fileSystem) { this.regexpScanner = regexpScanner; this.exclusionPatternInitializer = exclusionPatternInitializer; diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/ignore/scanner/RegexpScannerTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/ignore/scanner/IgnoreIssuesRegexpScannerTest.java index 3ab03f3e989..bfbe6c6aee0 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/ignore/scanner/RegexpScannerTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/ignore/scanner/IgnoreIssuesRegexpScannerTest.java @@ -41,9 +41,9 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -public class RegexpScannerTest { +public class IgnoreIssuesRegexpScannerTest { - private RegexpScanner regexpScanner; + private IgnoreIssuesRegexpScanner regexpScanner; private String javaFile; @Mock @@ -70,7 +70,7 @@ public class RegexpScannerTest { when(patternsInitializer.getBlockPatterns()).thenReturn(Arrays.asList(blockPattern1, blockPattern2)); when(patternsInitializer.getPatternMatcher()).thenReturn(patternMatcher); - regexpScanner = new RegexpScanner(patternsInitializer); + regexpScanner = new IgnoreIssuesRegexpScanner(patternsInitializer); verify(patternsInitializer, times(1)).getAllFilePatterns(); verify(patternsInitializer, times(1)).getBlockPatterns(); diff --git a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/ignore/scanner/SourceScannerTest.java b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/ignore/scanner/IgnoreIssuesSourceScannerTest.java index 98ec8ec805c..5fc3a27c648 100644 --- a/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/ignore/scanner/SourceScannerTest.java +++ b/plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/ignore/scanner/IgnoreIssuesSourceScannerTest.java @@ -50,12 +50,12 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyZeroInteractions; import static org.mockito.Mockito.when; -public class SourceScannerTest { +public class IgnoreIssuesSourceScannerTest { - private SourceScanner scanner; + private IgnoreIssuesSourceScanner scanner; @Mock - private RegexpScanner regexpScanner; + private IgnoreIssuesRegexpScanner regexpScanner; @Mock private InclusionPatternInitializer inclusionPatternInitializer; @Mock @@ -85,7 +85,7 @@ public class SourceScannerTest { Mockito.doReturn("java").when(project).getLanguageKey(); when(fs.sourceCharset()).thenReturn(UTF_8); - scanner = new SourceScanner(regexpScanner, exclusionPatternInitializer, inclusionPatternInitializer, fs); + scanner = new IgnoreIssuesSourceScanner(regexpScanner, exclusionPatternInitializer, inclusionPatternInitializer, fs); } @Test |