add IgnoreSection handling; will ignore every line containing IGNORE_BEGIN and following, until a line contains IGNORE_END
@@ -26,12 +26,36 @@ import edu.umd.cs.findbugs.annotations.CheckForNull;
import io.jenkins.plugins.analysis.core.util.LocalizedSeverity;
+
+class IgnoreSection {
+ private static final String IGNORE_BEGIN = " task-scanner-ignore-begin";
+ private static final String IGNORE_END = " task-scanner-ignore-end";
+
+ private boolean ignore = false;
+
+ public boolean matches(final String line) {
+ if (line.contains(IGNORE_BEGIN)) {
+ ignore = true;
+ } else if (line.contains(IGNORE_END)) {
+ ignore = false;
+ }
+
+ return ignore;
+ }
+
+ public void reset() {
+ ignore = false;
+ }
+}
+
/**
* Scans a given input stream for open tasks.
*
* @author Ullrich Hafner
*/
class TaskScanner {
+ private final IgnoreSection inIgnoreSection = new IgnoreSection();
+
private static final String WORD_BOUNDARY = "\\b";
private static final Pattern INVALID = Pattern.compile("");
@@ -232,9 +256,15 @@ class TaskScanner {
return report;
}
+ inIgnoreSection.reset();
+
for (int lineNumber = 1; lines.hasNext(); lineNumber++) {
String line = lines.next();
+ if (inIgnoreSection.matches(line)) {
+ continue;
+ }
+
for (Severity severity : Severity.getPredefinedValues()) {
if (patterns.containsKey(severity)) {
Matcher matcher = patterns.get(severity).matcher(line);
