# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: C:\work\hudson\hudson\plugins\tasks\src # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: main/java/hudson/plugins/tasks/parser/TaskScanner.java --- main/java/hudson/plugins/tasks/parser/TaskScanner.java Base (BASE) +++ main/java/hudson/plugins/tasks/parser/TaskScanner.java Locally Modified (Based On LOCAL) @@ -31,7 +31,7 @@ * Creates a new instance of TaskScanner. */ public TaskScanner() { - this("FIXME", "TODO", "@deprecated"); + this("FIXME", "TODO", "@deprecated", false); } /** @@ -43,16 +43,19 @@ * tag identifiers indicating normal priority * @param low * tag identifiers indicating low priority + * @param ignoreCase + * if case should be ignored during matching */ - public TaskScanner(final String high, final String normal, final String low) { + public TaskScanner(final String high, final String normal, final String low, + final boolean ignoreCase ) { if (StringUtils.isNotBlank(high)) { - patterns.put(Priority.HIGH, compile(high)); + patterns.put(Priority.HIGH, compile(high, ignoreCase)); } if (StringUtils.isNotBlank(normal)) { - patterns.put(Priority.NORMAL, compile(normal)); + patterns.put(Priority.NORMAL, compile(normal, ignoreCase)); } if (StringUtils.isNotBlank(low)) { - patterns.put(Priority.LOW, compile(low)); + patterns.put(Priority.LOW, compile(low, ignoreCase)); } } @@ -61,9 +64,11 @@ * * @param tagIdentifiers * the identifiers to scan for + * @param ignoreCase + * specifies if case should be ignored * @return the compiled pattern */ - private Pattern compile(final String tagIdentifiers) { + private Pattern compile(final String tagIdentifiers, final boolean ignoreCase) { try { String[] tags; if (tagIdentifiers.indexOf(',') == -1) { @@ -84,8 +89,13 @@ } } } - return Pattern.compile("^.*(?:" + StringUtils.join(regexps.iterator(), "|") + ")(.*)$"); + int flags = 0; + if( ignoreCase ) { + flags |= Pattern.CASE_INSENSITIVE; } + return Pattern.compile("^.*(?:" + StringUtils.join(regexps.iterator(), "|") + ")(.*)$", + flags); + } catch (PatternSyntaxException exception) { throw new AbortException("Invalid identifiers in a regular expression: " + tagIdentifiers + "\n", exception); } Index: main/java/hudson/plugins/tasks/parser/WorkspaceScanner.java --- main/java/hudson/plugins/tasks/parser/WorkspaceScanner.java Base (BASE) +++ main/java/hudson/plugins/tasks/parser/WorkspaceScanner.java Locally Modified (Based On LOCAL) @@ -41,11 +41,14 @@ private final String normal; /** Tag identifiers indicating low priority. */ private final String low; + /** Tag identifiers indicating case sensitive parsing. */ + private boolean ignoreCase; /** Prefix of path. */ private String prefix; /** The default encoding to be used when reading and parsing files. */ private final String defaultEncoding; + /** * Creates a new instance of WorkspaceScanner. * @@ -61,14 +64,18 @@ * tag identifiers indicating normal priority * @param low * tag identifiers indicating low priority + * @param ignoreCase + * if case should be ignored during matching */ - public WorkspaceScanner(final String filePattern, final String excludeFilePattern, final String defaultEncoding, final String high, final String normal, final String low) { + public WorkspaceScanner(final String filePattern, final String excludeFilePattern, final String defaultEncoding, + final String high, final String normal, final String low, final boolean ignoreCase) { this.filePattern = filePattern; this.excludeFilePattern = excludeFilePattern; this.defaultEncoding = defaultEncoding; this.high = high; this.normal = normal; this.low = low; + this.ignoreCase = ignoreCase; } /** @@ -89,8 +96,10 @@ * @param low * tag identifiers indicating low priority */ - public WorkspaceScanner(final String filePattern, final String excludeFilePattern, final String defaultEncoding, final String high, final String normal, final String low, final String moduleName) { - this(filePattern, excludeFilePattern, defaultEncoding, high, normal, low); + public WorkspaceScanner(final String filePattern, final String excludeFilePattern, final String defaultEncoding, + final String high, final String normal, final String low, final boolean caseSensitive, + final String moduleName) { + this(filePattern, excludeFilePattern, defaultEncoding, high, normal, low, caseSensitive); this.moduleName = moduleName; } @@ -120,7 +129,7 @@ detectors.add(new JavaPackageDetector()); detectors.add(new CsharpNamespaceDetector()); - TaskScanner taskScanner = new TaskScanner(high, normal, low); \ No newline at end of file + TaskScanner taskScanner = new TaskScanner(high, normal, low, ignoreCase); \ No newline at end of file TasksParserResult javaProject = new TasksParserResult(files.length); ModuleDetector moduleDetector = new ModuleDetector(workspace); Index: main/java/hudson/plugins/tasks/TasksPublisher.java --- main/java/hudson/plugins/tasks/TasksPublisher.java Base (BASE) +++ main/java/hudson/plugins/tasks/TasksPublisher.java Locally Modified (Based On LOCAL) @@ -34,6 +34,8 @@ private final String normal; /** Tag identifiers indicating low priority. */ private final String low; + /** Tag identifiers indicating case sensitivity. */ + private final boolean ignoreCase; /** Ant file-set pattern of files to work with. */ private final String pattern; /** Ant file-set pattern of files to exclude from work. */ @@ -66,6 +68,8 @@ * tag identifiers indicating normal priority * @param low * tag identifiers indicating low priority + * @param ignoreCase + * if case should be ignored during matching * @param defaultEncoding * the default encoding to be used when reading and parsing files */ @@ -74,13 +78,15 @@ @DataBoundConstructor public TasksPublisher(final String pattern, final String excludePattern, final String threshold, final String healthy, final String unHealthy, final String height, final Priority minimumPriority, - final String high, final String normal, final String low, final String defaultEncoding) { + final String high, final String normal, final String low, + final boolean ignoreCase, final String defaultEncoding) { super(threshold, healthy, unHealthy, height, minimumPriority, defaultEncoding, "TASKS"); this.pattern = pattern; this.excludePattern = excludePattern; this.high = high; this.normal = normal; + this.ignoreCase = ignoreCase; this.low = low; } // CHECKSTYLE:ON @@ -142,7 +148,8 @@ TasksParserResult project; log(logger, "Scanning workspace files for tasks..."); project = build.getProject().getWorkspace().act( - new WorkspaceScanner(StringUtils.defaultIfEmpty(getPattern(), DEFAULT_PATTERN), getExcludePattern(), getDefaultEncoding(), high, normal, low)); + new WorkspaceScanner(StringUtils.defaultIfEmpty(getPattern(), DEFAULT_PATTERN), + getExcludePattern(), getDefaultEncoding(), high, normal, low, ignoreCase) ); TasksResult result = new TasksResultBuilder().build(build, project, getDefaultEncoding(), high, normal, low); build.getActions().add(new TasksResultAction(build, this, result)); Index: main/java/hudson/plugins/tasks/TasksReporter.java --- main/java/hudson/plugins/tasks/TasksReporter.java Base (BASE) +++ main/java/hudson/plugins/tasks/TasksReporter.java Locally Modified (Based On LOCAL) @@ -46,6 +46,8 @@ private final String normal; /** Tag identifiers indicating low priority. */ private final String low; + /** Tag identifiers indicating case sensitivity. */ + private final boolean ignoreCase; /** The is threshold enabled. */ @SuppressWarnings("all") @@ -93,19 +95,22 @@ * tag identifiers indicating normal priority * @param low * tag identifiers indicating low priority + * @param ignoreCase + * if case should be ignored during matching */ // CHECKSTYLE:OFF @SuppressWarnings("PMD.ExcessiveParameterList") @DataBoundConstructor public TasksReporter(final String pattern, final String excludePattern, final String threshold, final String healthy, final String unHealthy, final String height, final Priority minimumPriority, - final String high, final String normal, final String low) { + final String high, final String normal, final String low, final boolean ignoreCase) { super(threshold, healthy, unHealthy, height, minimumPriority, "TASKS"); this.pattern = pattern; this.excludePattern = excludePattern; this.high = high; this.normal = normal; this.low = low; + this.ignoreCase = ignoreCase; } // CHECKSTYLE:ON @@ -154,6 +159,13 @@ return low; } + /** + * Returns if case should be ignored + */ + public boolean getIgnoreCase() { + return ignoreCase; + } + /** {@inheritDoc} */ @Override protected boolean acceptGoal(final String goal) { @@ -179,7 +191,7 @@ if (filePath.exists()) { log(logger, String.format("Scanning folder '%s' for tasks ... ", sourcePath)); WorkspaceScanner workspaceScanner = new WorkspaceScanner(StringUtils.defaultIfEmpty(pattern, DEFAULT_PATTERN), - excludePattern, getDefaultEncoding(), high, normal, low, pom.getName()); + excludePattern, getDefaultEncoding(), high, normal, low, ignoreCase, pom.getName()); workspaceScanner.setPrefix(sourcePath); TasksParserResult subProject = filePath.act(workspaceScanner); project.addAnnotations(subProject.getAnnotations()); Index: main/resources/hudson/plugins/tasks/config/tasks.jelly --- main/resources/hudson/plugins/tasks/config/tasks.jelly Base (BASE) +++ main/resources/hudson/plugins/tasks/config/tasks.jelly Locally Modified (Based On LOCAL) @@ -21,6 +21,7 @@ ${%High priority} ${%Normal priority} ${%Low priority} + ${%Ignore case} @@ -34,6 +35,9 @@ + + + \ No newline at end of file Index: main/resources/hudson/plugins/tasks/config/tasks.properties --- main/resources/hudson/plugins/tasks/config/tasks.properties Base (BASE) +++ main/resources/hudson/plugins/tasks/config/tasks.properties Locally Modified (Based On LOCAL) @@ -6,4 +6,5 @@ setting that specifies the workspace files to exclude scanning for tasks, such as library source files. \ Basedir of the fileset is the workspace root. description.tags=Configure the tags identifiers that should be looked for in the workspace files. \ - For each priority a comma separated list of tags could be defined, e.g. TODO, FIXME, etc. + For each priority a comma separated list of tags could be defined, e.g. TODO, FIXME, etc. \ + Case of the tga identifiers can be ignored, optionally. Index: main/resources/hudson/plugins/tasks/config/tasks_de.properties --- main/resources/hudson/plugins/tasks/config/tasks_de.properties Base (BASE) +++ main/resources/hudson/plugins/tasks/config/tasks_de.properties Locally Modified (Based On LOCAL) @@ -4,6 +4,7 @@ High\ priority=Hohe Priorität Normal\ priority=Normale Priorität Low\ priority=Niedrige Priorität +Ignore\ case=Groß-/Kleinschreibung ignorieren description.files=Angabe einer ANT Fileset 'includes' \ Anweisung, die den Pfad der zu untersuchenden Dateien bestimmt, z.B. '**/*.java'. \ @@ -13,4 +14,5 @@ Anweisung, die die Dateien angibt, die beim Scannen nicht berücksichtigt werden sollen, z.B. Dateien von Fremdbibliotheken. \ Als Ausgangsverzeichnis für diese Anweisung wird der Arbeitsbereich verwendet. description.tags=Konfiguriere die Texte, nach denen in den angegebenen Dateien gesucht werden soll. \ - Für jede Priorität kann eine durch Kommas getrennte Liste von Texten definiert werden, z.B. TODO, FIXME, o.a. + Für jede Priorität kann eine durch Kommas getrennte Liste von Texten definiert werden, z.B. TODO, FIXME, o.a. \ + Die Groß-/Kleinschreibung kann dabei optional ignoriert werden. Index: test/java/hudson/plugins/tasks/parser/TaskScannerTest.java --- test/java/hudson/plugins/tasks/parser/TaskScannerTest.java Base (BASE) +++ test/java/hudson/plugins/tasks/parser/TaskScannerTest.java Locally Modified (Based On LOCAL) @@ -38,7 +38,7 @@ public void scanFileWithWords() throws IOException { InputStream file = TaskScannerTest.class.getResourceAsStream("tasks-words-test.txt"); - Collection result = new TaskScanner("WARNING", "TODO", "@todo").scan(new InputStreamReader(file)); + Collection result = new TaskScanner("WARNING", "TODO", "@todo", false).scan(new InputStreamReader(file)); assignProperties(result); assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 12, result.size()); @@ -51,6 +51,62 @@ } /** + * Checks case sensitivity. + * + * @throws IOException if we can't read the file + */ + @Test + public void testCaseSensitive() throws IOException { + InputStream file = TaskScannerTest.class.getResourceAsStream("tasks-case-test.txt"); + + Collection result = new TaskScanner(null, "todo", null, false).scan(new InputStreamReader(file)); + assignProperties(result); + assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 1, result.size()); + } + + /** + * Checks case sensitivity. + * + * @throws IOException if we can't read the file + */ + @Test + public void testCaseSensitive2() throws IOException { + InputStream file = TaskScannerTest.class.getResourceAsStream("tasks-case-test.txt"); + + Collection result = new TaskScanner(null, "ToDo", null, false).scan(new InputStreamReader(file)); + assignProperties(result); + assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 1, result.size()); + } + + /** + * Checks case insensitivity. + * + * @throws IOException if we can't read the file + */ + @Test + public void testCaseInsensitive() throws IOException { + InputStream file = TaskScannerTest.class.getResourceAsStream("tasks-case-test.txt"); + + Collection result = new TaskScanner(null, "todo", null, true).scan(new InputStreamReader(file)); + assignProperties(result); + assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 9, result.size()); + } + + /** + * Checks case insensitivity. + * + * @throws IOException if we can't read the file + */ + @Test + public void testCaseInsensitive2() throws IOException { + InputStream file = TaskScannerTest.class.getResourceAsStream("tasks-case-test.txt"); + + Collection result = new TaskScanner(null, "Todo, TodoS", null, true).scan(new InputStreamReader(file)); + assignProperties(result); + assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 12, result.size()); + } + + /** * Checks whether we find the two task in the test file. * * @throws IOException if we can't read the file @@ -96,7 +152,7 @@ public void testHighPriority() throws IOException { InputStream file = TaskScannerTest.class.getResourceAsStream(FILE_WITH_TASKS); - Collection result = new TaskScanner("FIXME", null, null).scan(new InputStreamReader(file)); + Collection result = new TaskScanner("FIXME", null, null, false).scan(new InputStreamReader(file)); assignProperties(result); assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 1, result.size()); @@ -115,7 +171,7 @@ public void testTwoItemsWithWhiteSpaceAndHighPriority() throws IOException { InputStream file = TaskScannerTest.class.getResourceAsStream(FILE_WITH_TASKS); - Collection result = new TaskScanner(" FIXME , TODO ", null, null).scan(new InputStreamReader(file)); + Collection result = new TaskScanner(" FIXME , TODO ", null, null, false).scan(new InputStreamReader(file)); assignProperties(result); assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 2, result.size()); @@ -134,7 +190,7 @@ public void testTwoItemsWithHighPriority() throws IOException { InputStream file = TaskScannerTest.class.getResourceAsStream(FILE_WITH_TASKS); - Collection result = new TaskScanner("FIXME,TODO", null, null).scan(new InputStreamReader(file)); + Collection result = new TaskScanner("FIXME,TODO", null, null, false).scan(new InputStreamReader(file)); assignProperties(result); assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 2, result.size()); @@ -153,7 +209,7 @@ public void testAllPriorities() throws IOException { InputStream file = TaskScannerTest.class.getResourceAsStream(FILE_WITH_TASKS); - Collection result = new TaskScanner("FIXME", "FIXME,TODO", "TODO").scan(new InputStreamReader(file)); + Collection result = new TaskScanner("FIXME", "FIXME,TODO", "TODO", false).scan(new InputStreamReader(file)); assignProperties(result); assertEquals(WRONG_NUMBER_OF_TASKS_ERROR, 4, result.size()); Index: test/resources/hudson/plugins/tasks/parser/tasks-case-test.txt --- test/resources/hudson/plugins/tasks/parser/tasks-case-test.txt Locally New +++ test/resources/hudson/plugins/tasks/parser/tasks-case-test.txt Locally New @@ -0,0 +1,29 @@ +here we have a big TODO + +here we have a big TODO in a line + +TODO at the beginning + +here we have a TODO: + +here we have a TODO: in a line + +TODO: at the beginning + +:TODO; at the beginning + +here we have TODOS + +here we have TODOS in a line + +TODOS at the beginning + +here we have ATODO + +here we have ATODO in a line + +and here is a smalllll todo + +and a mixed cased ToDo + +