class 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;
    }

}

class TaskScannerTest  {

    private static final String FIXME;
    private static final String CASE_TEST_FILE;
    private static final String PRIORITY_HIGH_MESSAGE;
    private static final String PRIORITY_NORMAL_MESSAGE;
    private static final String FILE_WITH_TASKS;
    private static final IssueBuilder ISSUE_BUILDER;

    @Test
    void shouldScanFileWithoutTasks() {

        Report tasks = new TaskScannerBuilder().setHighTasks("FIXME")
                .setNormalTasks("TODO")
                .setLowTasks("@deprecated")
                .setCaseMode(CaseMode.CASE_SENSITIVE)
                .setMatcherMode(MatcherMode.STRING_MATCH)
                .build()
                .scanTasks(read("file-without-tasks.txt"), ISSUE_BUILDER);

        assertThat(tasks).hasSize(0);
    }

}