@Test void shouldIdentifyTags() { String text = "FIXME: this is a fixme"; Report high = new TaskScannerBuilder() .setHighTasks("FIXME,TODO") .setCaseMode(CaseMode.CASE_SENSITIVE) .setMatcherMode(MatcherMode.STRING_MATCH) .build() .scanTasks(readFromString(text), ISSUE_BUILDER); assertThat(high).hasSize(1); assertThat(high.get(0)).hasType(FIXME); Report normal = new TaskScannerBuilder() .setNormalTasks("XXX, HELP, FIXME, TODO") .setCaseMode(CaseMode.CASE_SENSITIVE) .setMatcherMode(MatcherMode.STRING_MATCH) .build() .scanTasks(readFromString(text), ISSUE_BUILDER); assertThat(normal).hasSize(1); assertThat(normal.get(0)).hasType(FIXME); }
Report scanTasks(final Iterator<String> lines, final IssueBuilder builder) { Report report = new Report(); if (isPatternInvalid) { report.logError("%s", errors.toString()); return report; } for (int lineNumber = 1; lines.hasNext(); lineNumber++) { String line = lines.next(); for (Severity severity : Severity.getPredefinedValues()) { if (patterns.containsKey(severity)) { Matcher matcher = patterns.get(severity).matcher(line); if (matcher.matches() && matcher.groupCount() == 2) { String message = matcher.group(2).trim(); builder.setMessage(StringUtils.removeStart(message, ":").trim()); String tag = matcher.group(1); if (isUppercase) { builder.setType(StringUtils.upperCase(tag)); } else { builder.setType(tag); } report.add(builder.setSeverity(severity).setLineStart(lineNumber).build()); } } } } return report; }
TaskScanner { Report scanTasks(final Iterator<String> lines, final IssueBuilder builder) { Report report = new Report(); if (isPatternInvalid) { report.logError("%s", errors.toString()); return report; } for (int lineNumber = 1; lines.hasNext(); lineNumber++) { String line = lines.next(); for (Severity severity : Severity.getPredefinedValues()) { if (patterns.containsKey(severity)) { Matcher matcher = patterns.get(severity).matcher(line); if (matcher.matches() && matcher.groupCount() == 2) { String message = matcher.group(2).trim(); builder.setMessage(StringUtils.removeStart(message, ":").trim()); String tag = matcher.group(1); if (isUppercase) { builder.setType(StringUtils.upperCase(tag)); } else { builder.setType(tag); } report.add(builder.setSeverity(severity).setLineStart(lineNumber).build()); } } } } return report; } }
TaskScanner { Report scanTasks(final Iterator<String> lines, final IssueBuilder builder) { Report report = new Report(); if (isPatternInvalid) { report.logError("%s", errors.toString()); return report; } for (int lineNumber = 1; lines.hasNext(); lineNumber++) { String line = lines.next(); for (Severity severity : Severity.getPredefinedValues()) { if (patterns.containsKey(severity)) { Matcher matcher = patterns.get(severity).matcher(line); if (matcher.matches() && matcher.groupCount() == 2) { String message = matcher.group(2).trim(); builder.setMessage(StringUtils.removeStart(message, ":").trim()); String tag = matcher.group(1); if (isUppercase) { builder.setType(StringUtils.upperCase(tag)); } else { builder.setType(tag); } report.add(builder.setSeverity(severity).setLineStart(lineNumber).build()); } } } } return report; } TaskScanner(final @CheckForNull String highTags, final @CheckForNull String normalTags,
            final @CheckForNull String lowTags,
            final CaseMode caseMode, final MatcherMode matcherMode); }
TaskScanner { Report scanTasks(final Iterator<String> lines, final IssueBuilder builder) { Report report = new Report(); if (isPatternInvalid) { report.logError("%s", errors.toString()); return report; } for (int lineNumber = 1; lines.hasNext(); lineNumber++) { String line = lines.next(); for (Severity severity : Severity.getPredefinedValues()) { if (patterns.containsKey(severity)) { Matcher matcher = patterns.get(severity).matcher(line); if (matcher.matches() && matcher.groupCount() == 2) { String message = matcher.group(2).trim(); builder.setMessage(StringUtils.removeStart(message, ":").trim()); String tag = matcher.group(1); if (isUppercase) { builder.setType(StringUtils.upperCase(tag)); } else { builder.setType(tag); } report.add(builder.setSeverity(severity).setLineStart(lineNumber).build()); } } } } return report; } TaskScanner(final @CheckForNull String highTags, final @CheckForNull String normalTags,
            final @CheckForNull String lowTags,
            final CaseMode caseMode, final MatcherMode matcherMode); String getErrors(); Report scan(final Path file, final Charset charset); }
TaskScanner { Report scanTasks(final Iterator<String> lines, final IssueBuilder builder) { Report report = new Report(); if (isPatternInvalid) { report.logError("%s", errors.toString()); return report; } for (int lineNumber = 1; lines.hasNext(); lineNumber++) { String line = lines.next(); for (Severity severity : Severity.getPredefinedValues()) { if (patterns.containsKey(severity)) { Matcher matcher = patterns.get(severity).matcher(line); if (matcher.matches() && matcher.groupCount() == 2) { String message = matcher.group(2).trim(); builder.setMessage(StringUtils.removeStart(message, ":").trim()); String tag = matcher.group(1); if (isUppercase) { builder.setType(StringUtils.upperCase(tag)); } else { builder.setType(tag); } report.add(builder.setSeverity(severity).setLineStart(lineNumber).build()); } } } } return report; } TaskScanner(final @CheckForNull String highTags, final @CheckForNull String normalTags,
            final @CheckForNull String lowTags,
            final CaseMode caseMode, final MatcherMode matcherMode); String getErrors(); Report scan(final Path file, final Charset charset);  }