Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-12822] Added support for columns in Eclipse warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Feb 20, 2012
1 parent eccd272 commit 82b0b4c
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -36,7 +36,7 @@
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-core</artifactId>
<version>1.36</version>
<version>1.38-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jvnet.hudson.plugins</groupId>
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/hudson/plugins/warnings/parser/EclipseParser.java
Expand Up @@ -15,10 +15,10 @@ public class EclipseParser extends RegexpDocumentParser {
/** Warning type of this parser. */
static final String WARNING_TYPE = "Eclipse Java Compiler";
/** Pattern of javac compiler warnings. */
private static final String ANT_ECLIPSE_WARNING_PATTERN = "(WARNING|ERROR)\\s*in\\s*(.*)\\(at line\\s*(\\d+)\\).*(?:\\r?\\n[^\\^]*)+(?:\\r?\\n.*[\\^]+.*)\\r?\\n(?:\\s*\\[.*\\]\\s*)?(.*)";
private static final String ANT_ECLIPSE_WARNING_PATTERN = "(WARNING|ERROR)\\s*in\\s*(.*)\\(at line\\s*(\\d+)\\).*(?:\\r?\\n[^\\^]*)+(?:\\r?\\n(.*)([\\^]+).*)\\r?\\n(?:\\s*\\[.*\\]\\s*)?(.*)";

/**
* Creates a new instance of <code>AntJavacParser</code>.
* Creates a new instance of <code>EclipseParser</code>.
*/
public EclipseParser() {
super(ANT_ECLIPSE_WARNING_PATTERN, true, WARNING_TYPE);
Expand All @@ -27,7 +27,8 @@ public EclipseParser() {
/**
* Creates a new annotation for the specified pattern.
*
* @param matcher the regular expression matcher
* @param matcher
* the regular expression matcher
* @return a new annotation for the specified pattern
*/
@Override
Expand All @@ -40,7 +41,13 @@ protected Warning createWarning(final Matcher matcher) {
else {
priority = Priority.HIGH;
}
return new Warning(matcher.group(2), getLineNumber(matcher.group(3)), WARNING_TYPE, StringUtils.EMPTY, matcher.group(4), priority);
Warning warning = new Warning(matcher.group(2), getLineNumber(matcher.group(3)), WARNING_TYPE, StringUtils.EMPTY, matcher.group(6), priority);

int columnStart = StringUtils.defaultString(matcher.group(4)).length();
int columnEnd = columnStart + matcher.group(5).length();
warning.setColumnPosition(columnStart, columnEnd);

return warning;
}
}

@@ -1,6 +1,7 @@
package hudson.plugins.warnings.parser;



/**
* Tests the class {@link DynamicDocumentParser}.
*
Expand All @@ -14,8 +15,9 @@ public class DynamicDocumentParserTest extends EclipseParserTest {
protected WarningsParser createParser() {
// CHECKSTYLE:OFF
return new DynamicDocumentParser("Eclipse Dynamic",
"(WARNING|ERROR)\\s*in\\s*(.*)\\(at line\\s*(\\d+)\\).*(?:\\r?\\n[^\\^]*)+(?:\\r?\\n.*[\\^]+.*)\\r?\\n(?:\\s*\\[.*\\]\\s*)?(.*)",
"(WARNING|ERROR)\\s*in\\s*(.*)\\(at line\\s*(\\d+)\\).*(?:\\r?\\n[^\\^]*)+(?:\\r?\\n(.*)([\\^]+).*)\\r?\\n(?:\\s*\\[.*\\]\\s*)?(.*)",
"import hudson.plugins.warnings.parser.Warning\n" +
"import org.apache.commons.lang.StringUtils\n" +
"import hudson.plugins.analysis.util.model.Priority\n" +
"String type = matcher.group(1)\n" +
"Priority priority;\n" +
Expand All @@ -27,8 +29,14 @@ protected WarningsParser createParser() {
"}\n" +
"String fileName = matcher.group(2)\n" +
"String lineNumber = matcher.group(3)\n" +
"String message = matcher.group(4)\n" +
"return new Warning(fileName, Integer.parseInt(lineNumber), \"" + TYPE + "\", \"\", message);\n");
"String message = matcher.group(6)\n" +
"Warning warning = new Warning(fileName, Integer.parseInt(lineNumber), \"" + TYPE + "\", \"\", message);\n" +
"\n" +
"int columnStart = StringUtils.defaultString(matcher.group(4)).length();\n" +
"int columnEnd = columnStart + matcher.group(5).length();\n" +
"warning.setColumnPosition(columnStart, columnEnd);\n" +
"\n" +
" return warning;\n");
// CHECKSTYLE:ON
}

Expand Down
@@ -1,6 +1,7 @@
package hudson.plugins.warnings.parser;

import static junit.framework.Assert.*;
import hudson.plugins.analysis.core.ParserResult;
import hudson.plugins.analysis.util.model.FileAnnotation;
import hudson.plugins.analysis.util.model.Priority;

Expand All @@ -18,6 +19,23 @@
* Tests the class {@link EclipseParser}.
*/
public class EclipseParserTest extends ParserTester {
/**
* Parses a warning log with 15 warnings.
*
* @throws IOException
* if the file could not be read
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-12822">Issue 12822</a>
*/
@Test
public void issue12822() throws IOException {
Collection<FileAnnotation> warnings = createParser().parse(openFile("issue12822.txt"));

assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 15, warnings.size());

ParserResult result = new ParserResult(warnings);
assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 15, result.getNumberOfAnnotations());
}

/**
* Parses a warning log with console annotations which are removed.
*
Expand Down Expand Up @@ -116,12 +134,12 @@ public void issue7077() throws IOException {

assertEquals(WRONG_NUMBER_OF_WARNINGS_DETECTED, 2, warnings.size());

checkWarning(sorted.get(1),
checkWarning(sorted.get(0),
90,
"Type safety: The method setBoHandler(BoHandler) belongs to the raw type BoQuickSearchControl.Builder. References to generic type BoQuickSearchControl<S>.Builder<T> should be parameterized",
"/ige/hudson/work/jobs/esvclient__development/workspace/target/rcp-build/plugins/ch.ipi.esv.client.customer/src/main/java/ch/ipi/esv/client/customer/search/CustomerQuickSearch.java",
getType(), "", Priority.NORMAL);
checkWarning(sorted.get(0),
checkWarning(sorted.get(1),
90,
"Type safety: The expression of type BoQuickSearchControl needs unchecked conversion to conform to BoQuickSearchControl<CustomerBO>",
"/ige/hudson/work/jobs/esvclient__development/workspace/target/rcp-build/plugins/ch.ipi.esv.client.customer/src/main/java/ch/ipi/esv/client/customer/search/CustomerQuickSearch.java",
Expand Down
79 changes: 79 additions & 0 deletions src/test/resources/hudson/plugins/warnings/parser/issue12822.txt
@@ -0,0 +1,79 @@
----------
1. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/editingsupport/EnumEditingSupport.java (at line 23)
import org.faktorips.devtools.core.enums.EnumValue;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The type EnumValue is deprecated
----------
2. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/editingsupport/EnumEditingSupport.java (at line 60)
EnumValue[] enumValues = enumType.getValues();
^^^^^^^^^
The type EnumValue is deprecated
----------
3. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/editingsupport/EnumEditingSupport.java (at line 63)
strValues[i] = enumValues[i].getName();
^^^^^^^^^
The method getName() from the type EnumValue is deprecated
----------
4. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/editingsupport/EnumEditingSupport.java (at line 68)
private int valueOf(EnumValue[] values, EnumValue value) {
^^^^^^^^^
The type EnumValue is deprecated
----------
5. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/editingsupport/EnumEditingSupport.java (at line 68)
private int valueOf(EnumValue[] values, EnumValue value) {
^^^^^^^^^
The type EnumValue is deprecated
----------
6. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/editingsupport/EnumEditingSupport.java (at line 71)
if (value == null || values[i].getId().equalsIgnoreCase(value.getId())) {
^^^^^^^
The method getId() from the type EnumValue is deprecated
----------
7. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/editingsupport/EnumEditingSupport.java (at line 71)
if (value == null || values[i].getId().equalsIgnoreCase(value.getId())) {
^^^^^^^
The method getId() from the type EnumValue is deprecated
----------
8. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/editingsupport/EnumEditingSupport.java (at line 90)
cellEditor.setValue(valueOf(enumType.getValues(), (EnumValue)getLabelModifyer().getValue(cell.getElement())));
^^^^^^^^^
The type EnumValue is deprecated
----------
----------
9. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/labelprovider/EnumExtPropertyLabelModifier.java (at line 19)
import org.faktorips.devtools.core.enums.EnumValue;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The type EnumValue is deprecated
----------
10. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/labelprovider/EnumExtPropertyLabelModifier.java (at line 45)
EnumValue ev = (EnumValue)ipsObject.getExtPropertyValue(getExtesionProperty().getPropertyId());
^^^^^^^^^
The type EnumValue is deprecated
----------
11. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/labelprovider/EnumExtPropertyLabelModifier.java (at line 45)
EnumValue ev = (EnumValue)ipsObject.getExtPropertyValue(getExtesionProperty().getPropertyId());
^^^^^^^^^
The type EnumValue is deprecated
----------
12. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/labelprovider/EnumExtPropertyLabelModifier.java (at line 47)
ev = (EnumValue)getExtesionProperty().getDefaultValue();
^^^^^^^^^
The type EnumValue is deprecated
----------
13. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/views/qr/labelprovider/EnumExtPropertyLabelModifier.java (at line 50)
text = ev.getName();
^^^^^^^^^
The method getName() from the type EnumValue is deprecated
----------
----------
14. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/ext/ComboBoxRuleOverruledByExtensionPropertyFactory.java (at line 19)
import org.faktorips.devtools.core.enums.EnumValue;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The type EnumValue is deprecated
----------
15. WARNING in /media/ssd/multi-x-processor/workspace/Product_Analyzer/org.faktorips.analysis.ui/src/org/faktorips/analysis/ui/ext/ComboBoxRuleOverruledByExtensionPropertyFactory.java (at line 43)
EnumValue defaultValue = AnalysisActivator.getRuleOverruledBy().getEnumValue(0);
^^^^^^^^^
The type EnumValue is deprecated
----------
15 problems (15 warnings)

0 comments on commit 82b0b4c

Please sign in to comment.