diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2018-12-14 19:35:50 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2019-01-16 09:43:10 +0100 |
commit | bbff7949d06677e808d7c6f2cf4fd7cfc1f1a079 (patch) | |
tree | 2333a2f05764d9e00833fda00c142d776b2d1387 /sonar-plugin-api/src/main/java/org/sonar/api/batch | |
parent | 4db8bd9ecf0584443a2e5a9c369970e6ee85f48f (diff) | |
download | sonarqube-bbff7949d06677e808d7c6f2cf4fd7cfc1f1a079.tar.gz sonarqube-bbff7949d06677e808d7c6f2cf4fd7cfc1f1a079.zip |
SONAR-11587 Rework issue exclusions
Diffstat (limited to 'sonar-plugin-api/src/main/java/org/sonar/api/batch')
-rw-r--r-- | sonar-plugin-api/src/main/java/org/sonar/api/batch/fs/internal/DefaultInputFile.java | 22 |
1 files changed, 22 insertions, 0 deletions
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 01316b2ad30..0b60c5e227c 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 @@ -29,7 +29,9 @@ import java.net.URI; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.HashSet; import java.util.Set; import java.util.function.Consumer; @@ -59,6 +61,8 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile private boolean published; private boolean excludedForCoverage; private final Set<Integer> noSonarLines = new HashSet<>(); + private boolean ignoreAllIssues; + private Collection<int[]> ignoreIssuesOnlineRanges = new ArrayList<>(); public DefaultInputFile(DefaultIndexedFile indexedFile, Consumer<DefaultInputFile> metadataGenerator) { this(indexedFile, metadataGenerator, null); @@ -376,4 +380,22 @@ public class DefaultInputFile extends DefaultInputComponent implements InputFile return this.noSonarLines.contains(line); } + public boolean isIgnoreAllIssues() { + return ignoreAllIssues; + } + + public void setIgnoreAllIssues(boolean ignoreAllIssues) { + this.ignoreAllIssues = ignoreAllIssues; + } + + public void addIgnoreIssuesOnLineRanges(Collection<int[]> lineRanges) { + this.ignoreIssuesOnlineRanges.addAll(lineRanges); + } + + public boolean isIgnoreAllIssuesOnLine(@Nullable Integer line) { + if (line == null) { + return false; + } + return ignoreIssuesOnlineRanges.stream().anyMatch(r -> r[0] <= line && line <= r[1]); + } } |