Skip to content

Commit

Permalink
[FIXED JENKINS-51485] Support '-' and '_' in category names.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed May 25, 2018
1 parent 535fd19 commit d1ca011
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/main/java/edu/hm/hafner/analysis/parser/MsBuildParser.java
Expand Up @@ -18,11 +18,12 @@
public class MsBuildParser extends RegexpLineParser {
private static final long serialVersionUID = -2141974437420906595L;

private static final String MS_BUILD_WARNING_PATTERN = "(?:^(?:.*)Command line warning ([A-Za-z0-9]+):\\s*(.*)"
+ "\\s*\\[(.*)\\])|" + ANT_TASK + "(?:(?:\\s*\\d+>)?(?:(?:(?:(.*)\\((\\d*)(?:,(\\d+))?.*\\)|.*LINK)\\s*:|("
+ ".*):)\\s*([A-z-_]*\\s?(?:[Nn]ote|[Ii]nfo|[Ww]arning|(?:fatal\\s*)?[Ee]rror))\\s*:?\\s*([A-Za-z0-9]+)"
+ "\\s*:\\s(?:\\s*([A-Za-z0-9.]+)\\s*:)?\\s*(.*?)(?: \\[([^\\]]*)[/\\\\][^\\]\\\\]+\\])?" + "|(.*)\\s*:"
+ ".*error\\s*(LNK[0-9]+):\\s*(.*)))$";
private static final String MS_BUILD_WARNING_PATTERN
= "(?:^(?:.*)Command line warning ([A-Za-z0-9]+):\\s*(.*)\\s*\\[(.*)\\])|"
+ ANT_TASK + "(?:(?:\\s*\\d+>)?(?:(?:(?:(.*)\\((\\d*)(?:,(\\d+))?.*\\)|.*LINK)\\s*:|"
+ "(.*):)\\s*([A-z-_]*\\s?(?:[Nn]ote|[Ii]nfo|[Ww]arning|(?:fatal\\s*)?[Ee]rror))\\s*:?\\s*([A-Za-z0-9\\-_]+)"
+ "\\s*:\\s(?:\\s*([A-Za-z0-9.]+)\\s*:)?\\s*(.*?)(?: \\[([^\\]]*)[/\\\\][^\\]\\\\]+\\])?"
+ "|(.*)\\s*:.*error\\s*(LNK[0-9]+):\\s*(.*)))$";

/**
* Creates a new instance of {@link MsBuildParser}.
Expand Down
29 changes: 29 additions & 0 deletions src/test/java/edu/hm/hafner/analysis/parser/MsBuildParserTest.java
Expand Up @@ -89,6 +89,35 @@ void issue22386() {
});
}

/**
* MSBuildParser should support SASS messages with '-' and '_' in category.
*
* @see <a href="https://issues.jenkins-ci.org/browse/JENKINS-51485">Issue 51485</a>
*/
@Test
void issue51485() {
Report warnings = parse("issue51485.txt");

assertThat(warnings)
.hasSize(2)
.hasPriorities(0, 2, 0);

assertSoftly(softly -> {
softly.assertThat(warnings.get(0))
.hasFileName("src/search-list.component.scss")
.hasCategory("shorthand-values")
.hasPriority(Priority.NORMAL)
.hasMessage("Property `margin` should be written more concisely as `5px 0 0` instead of `5px 0 0 0`")
.hasLineStart(41).hasColumnStart(17);
softly.assertThat(warnings.get(1))
.hasFileName("src/search-list.component.scss")
.hasCategory("shorthand_values")
.hasPriority(Priority.NORMAL)
.hasMessage("Property `margin` should be written more concisely as `5px 0 0` instead of `5px 0 0 0`")
.hasLineStart(42).hasColumnStart(18);
});
}

/**
* MSBuildParser should also detect subcategories as described at <a href="http://blogs.msdn.com/b/msbuild/archive/2006/11/03/msbuild-visual-studio-aware-error-messages-and-message-formats.aspx">
* MSBuild / Visual Studio aware error messages and message formats</a>.
Expand Down
@@ -0,0 +1,3 @@
src/search-list.component.scss(41,17): warning shorthand-values : Property `margin` should be written more concisely as `5px 0 0` instead of `5px 0 0 0`
src/search-list.component.scss(42,18): warning shorthand_values : Property `margin` should be written more concisely as `5px 0 0` instead of `5px 0 0 0`

0 comments on commit d1ca011

Please sign in to comment.