Warnings Plugin: New Parser for Buckminster

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Warnings Plugin: New Parser for Buckminster

Johannes Utzig
Hi,

I would like to submit a patch for a new parser for the warnings plugin
and I was hoping that you'd be willing to include it.
It's for parsing the output of eclipse buckminster. See the recently
added buckminster plugin
http://wiki.hudson-ci.org/display/HUDSON/Buckminster+PlugIn

If something's wrong or missing, please let me know, patch is attached.

Best regards,
Johannes

Index: src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java
===================================================================
--- src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java (revision 19475)
+++ src/main/java/hudson/plugins/warnings/parser/ParserRegistry.java (working copy)
@@ -80,7 +80,7 @@
 
         if (!StringUtils.isEmpty(includePattern) || !StringUtils.isEmpty(excludePattern)) {
             fileFilter = new FileFilter(includePattern, excludePattern);
-        }
+        }
         else {
             fileFilter = null;
         }
@@ -204,13 +204,13 @@
 
             if (StringUtils.isEmpty(includePattern)) {
                 setIncludes(new String[] {"**/*"});
-            }
+            }
             else {
                 setIncludes(includePattern.split(",\\s*"));
             }
             if (StringUtils.isEmpty(excludePattern)) {
                 setExcludes(new String[] {});
-            }
+            }
             else {
                 setExcludes(excludePattern.split(",\\s*"));
             }
@@ -231,7 +231,7 @@
             final String canonicalName;
             if (File.separatorChar == '\\') {
                 canonicalName = StringUtils.replaceChars(name, '/', '\\');
-            }
+            }
             else {
                 canonicalName = name;
             }
@@ -261,7 +261,7 @@
         MsBuildParser pclintParser = new MsBuildParser();
         pclintParser.setName("PC-Lint");
         parsers.add(pclintParser);
-
+        parsers.add(new BuckminsterParser());
         return Collections.unmodifiableList(parsers);
     }
 
Index: src/main/java/hudson/plugins/warnings/parser/BuckminsterParser.java
===================================================================
--- src/main/java/hudson/plugins/warnings/parser/BuckminsterParser.java (revision 0)
+++ src/main/java/hudson/plugins/warnings/parser/BuckminsterParser.java (revision 0)
@@ -0,0 +1,35 @@
+package hudson.plugins.warnings.parser;
+
+import java.util.regex.Matcher;
+
+/**
+ * A parser for Buckminster compiler warnings.
+ *
+ * @author Johannes Utzig
+ */
+public class BuckminsterParser extends RegexpLineParser {
+    /** Warning type of this parser. */
+    static final String WARNING_TYPE = "Buckminster Compiler";
+    /** Pattern for buckminster compiler warnings. */
+    private static final String BUCKMINSTER_WARNING_PATTERN = "^.*(Warning: file )(.*?)(, line )?(\\d*): (.*)$";
+
+    /**
+     * Creates a new instance of <code>BuckminsterParser</code>.
+     */
+    public BuckminsterParser() {
+        super(BUCKMINSTER_WARNING_PATTERN, WARNING_TYPE);
+    }
+
+    /**
+     * Creates a new annotation for the specified pattern.
+     *
+     * @param matcher the regular expression matcher
+     * @return a new annotation for the specified pattern
+     */
+    @Override
+    protected Warning createWarning(final Matcher matcher) {
+        return new Warning(matcher.group(2), getLineNumber(matcher.group(4)), WARNING_TYPE, classifyWarning(matcher.group(5)), matcher.group(5));
+
+    }
+}
+


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Warnings Plugin: New Parser for Buckminster

Ulli Hafner-2
Thanks for your work,

I added the patch (SVN rev 19479). Can you please also add a small test
case?
Otherwise it's hard to ensure that there are no false positives in
future releases.

Ulli

> -----Original Message-----
> From: Johannes Utzig [mailto:[hidden email]]
> Sent: Dienstag, 7. Juli 2009 22:16
> To: [hidden email]
> Subject: Warnings Plugin: New Parser for Buckminster
>
> Hi,
>
> I would like to submit a patch for a new parser for the
> warnings plugin and I was hoping that you'd be willing to include it.
> It's for parsing the output of eclipse buckminster. See the
> recently added buckminster plugin
> http://wiki.hudson-ci.org/display/HUDSON/Buckminster+PlugIn
>
> If something's wrong or missing, please let me know, patch is
> attached.
>
> Best regards,
> Johannes
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Warnings Plugin: New Parser for Buckminster

Johannes Utzig
Hi Ullrich,

wow, that was fast :)

Is the attached test case sufficient?

Thank you very much and best regards,
Johannes


Hafner Ullrich schrieb:

> Thanks for your work,
>
> I added the patch (SVN rev 19479). Can you please also add a small test
> case?
> Otherwise it's hard to ensure that there are no false positives in
> future releases.
>
> Ulli
>
>  
>> -----Original Message-----
>> From: Johannes Utzig [mailto:[hidden email]]
>> Sent: Dienstag, 7. Juli 2009 22:16
>> To: [hidden email]
>> Subject: Warnings Plugin: New Parser for Buckminster
>>
>> Hi,
>>
>> I would like to submit a patch for a new parser for the
>> warnings plugin and I was hoping that you'd be willing to include it.
>> It's for parsing the output of eclipse buckminster. See the
>> recently added buckminster plugin
>> http://wiki.hudson-ci.org/display/HUDSON/Buckminster+PlugIn
>>
>> If something's wrong or missing, please let me know, patch is
>> attached.
>>
>> Best regards,
>> Johannes
>>
>>    
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  

Index: src/test/java/hudson/plugins/warnings/parser/BuckminsterParserTest.java
===================================================================
--- src/test/java/hudson/plugins/warnings/parser/BuckminsterParserTest.java (revision 0)
+++ src/test/java/hudson/plugins/warnings/parser/BuckminsterParserTest.java (revision 0)
@@ -0,0 +1,63 @@
+package hudson.plugins.warnings.parser;
+
+import static junit.framework.Assert.*;
+import hudson.plugins.warnings.util.model.FileAnnotation;
+import hudson.plugins.warnings.util.model.Priority;
+
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.junit.Test;
+
+/**
+ * Tests the class {@link BuckminsterParser}.
+ */
+public class BuckminsterParserTest extends ParserTester {
+    /**
+     * Creates a new instance of {@link BuckminsterParser}.
+     */
+    public BuckminsterParserTest() {
+        super(BuckminsterParser.class);
+    }
+
+    /**
+     * Parses a file with three Buckminster warnings.
+     *
+     * @throws IOException
+     *      if the file could not be read
+     */
+    @Test
+    public void testWarningsParser() throws IOException {
+        Collection<FileAnnotation> warnings = new BuckminsterParser().parse(openFile());
+
+        assertEquals("Wrong number of warnings detected.", 3, warnings.size());
+
+        Iterator<FileAnnotation> iterator = warnings.iterator();
+        FileAnnotation annotation = iterator.next();
+        checkWarning(annotation,
+                43,
+                "ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized",
+                "/var/lib/hudson/jobs/MailApp/workspace/plugins/org.eclipse.buckminster.tutorial.mailapp/src/org/eclipse/buckminster/tutorial/mailapp/NavigationView.java",
+                BuckminsterParser.WARNING_TYPE, "", Priority.NORMAL);
+        annotation = iterator.next();
+        checkWarning(annotation,
+                57,
+                "Type safety: The method toArray(Object[]) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized",
+                "/var/lib/hudson/jobs/MailApp/workspace/plugins/org.eclipse.buckminster.tutorial.mailapp/src/org/eclipse/buckminster/tutorial/mailapp/NavigationView.java",
+                BuckminsterParser.WARNING_TYPE, "", Priority.NORMAL);
+        annotation = iterator.next();
+        checkWarning(annotation,
+                0,
+                "Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.",
+                "/var/lib/hudson/jobs/MailApp/workspace/plugins/org.eclipse.buckminster.tutorial.mailapp",
+                BuckminsterParser.WARNING_TYPE, "", Priority.NORMAL);
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    protected String getWarningsFile() {
+        return "buckminster.txt";
+    }
+}
+
Index: src/test/resources/hudson/plugins/warnings/parser/buckminster.txt
===================================================================
--- src/test/resources/hudson/plugins/warnings/parser/buckminster.txt (revision 0)
+++ src/test/resources/hudson/plugins/warnings/parser/buckminster.txt (revision 0)
@@ -0,0 +1,78 @@
+INFO:  Import complete.
+INFO:  perform '-D' 'buckminster.output.root=/var/lib/hudson/jobs/MailApp/workspace/buckminster.output' 'org.eclipse.buckminster.tutorial.mailapp.product.feature#create.product.zip'
+INFO:  [start org.eclipse.swt:osgi.bundle$3.5.0.v3550b#OSGi#target.fragments]
+INFO:  [end org.eclipse.swt:osgi.bundle$3.5.0.v3550b#OSGi#target.fragments]
+INFO:  [start org.eclipse.equinox.launcher:osgi.bundle$1.0.200.v20090520#OSGi#target.fragments]
+INFO:  [start org.eclipse.equinox.launcher.gtk.linux.x86_64:osgi.bundle$1.0.200.v20090519#OSGi#bundle.jar]
+INFO:  [end org.eclipse.equinox.launcher.gtk.linux.x86_64:osgi.bundle$1.0.200.v20090519#OSGi#bundle.jar]
+INFO:  [end org.eclipse.equinox.launcher:osgi.bundle$1.0.200.v20090520#OSGi#target.fragments]
+INFO:  [start org.eclipse.ecf:osgi.bundle$3.0.0.v20090604-1131#OSGi#target.fragments]
+INFO:  [end org.eclipse.ecf:osgi.bundle$3.0.0.v20090604-1131#OSGi#target.fragments]
+INFO:  [start org.eclipse.ecf.provider.filetransfer:osgi.bundle$3.0.0.v20090604-1131#OSGi#target.fragments]
+INFO:  [end org.eclipse.ecf.provider.filetransfer:osgi.bundle$3.0.0.v20090604-1131#OSGi#target.fragments]
+INFO:  [start org.eclipse.ecf.provider.filetransfer.httpclient:osgi.bundle$3.0.0.v20090604-1131#OSGi#target.fragments]
+INFO:  [end org.eclipse.ecf.provider.filetransfer.httpclient:osgi.bundle$3.0.0.v20090604-1131#OSGi#target.fragments]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp:osgi.bundle$1.0.0#OSGi#eclipse.build]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp:osgi.bundle$1.0.0#OSGi#eclipse.build]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp:osgi.bundle$1.0.0#OSGi#bundle.jar]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp:osgi.bundle$1.0.0#OSGi#bundle.jar]
+INFO:  [start org.eclipse.rcp:eclipse.feature$3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11#OSGi#manifest]
+INFO:  [end org.eclipse.rcp:eclipse.feature$3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11#OSGi#manifest]
+INFO:  [start org.eclipse.rcp:eclipse.feature$3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11#OSGi#feature.jar]
+INFO:  [end org.eclipse.rcp:eclipse.feature$3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11#OSGi#feature.jar]
+INFO:  [start org.eclipse.equinox.p2.user.ui:eclipse.feature$1.1.0.v20090605-1440-7u6Fb3FbPbJP5MjJjZgifk#OSGi#manifest]
+INFO:  [end org.eclipse.equinox.p2.user.ui:eclipse.feature$1.1.0.v20090605-1440-7u6Fb3FbPbJP5MjJjZgifk#OSGi#manifest]
+INFO:  [start org.eclipse.equinox.p2.user.ui:eclipse.feature$1.1.0.v20090605-1440-7u6Fb3FbPbJP5MjJjZgifk#OSGi#feature.jar]
+INFO:  [end org.eclipse.equinox.p2.user.ui:eclipse.feature$1.1.0.v20090605-1440-7u6Fb3FbPbJP5MjJjZgifk#OSGi#feature.jar]
+INFO:  [start org.eclipse.buckminster.tutorial.rcpp2.feature:eclipse.feature$1.0.0#OSGi#manifest]
+INFO:  [end org.eclipse.buckminster.tutorial.rcpp2.feature:eclipse.feature$1.0.0#OSGi#manifest]
+INFO:  [start org.eclipse.buckminster.tutorial.rcpp2.feature:eclipse.feature$1.0.0#OSGi#feature.jar]
+INFO:  [end org.eclipse.buckminster.tutorial.rcpp2.feature:eclipse.feature$1.0.0#OSGi#feature.jar]
+INFO:  [start org.eclipse.equinox.executable:eclipse.feature$3.3.200.v20090521-1800-7M-Fm-FI3UouOe61h3BYGC#OSGi#manifest]
+INFO:  [end org.eclipse.equinox.executable:eclipse.feature$3.3.200.v20090521-1800-7M-Fm-FI3UouOe61h3BYGC#OSGi#manifest]
+INFO:  [start org.eclipse.equinox.executable:eclipse.feature$3.3.200.v20090521-1800-7M-Fm-FI3UouOe61h3BYGC#OSGi#feature.jar]
+INFO:  [end org.eclipse.equinox.executable:eclipse.feature$3.3.200.v20090521-1800-7M-Fm-FI3UouOe61h3BYGC#OSGi#feature.jar]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#manifest]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#manifest]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#feature.jar]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#feature.jar]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp:osgi.bundle$1.0.0#OSGi#source.manifest]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp:osgi.bundle$1.0.0#OSGi#source.manifest]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp:osgi.bundle$1.0.0#OSGi#source.bundle.jar]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp:osgi.bundle$1.0.0#OSGi#source.bundle.jar]
+INFO:  [start org.eclipse.rcp:eclipse.feature$3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11#OSGi#source.manifest]
+INFO:  [end org.eclipse.rcp:eclipse.feature$3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11#OSGi#source.manifest]
+INFO:  [start org.eclipse.rcp:eclipse.feature$3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11#OSGi#source.feature.jar]
+INFO:  [end org.eclipse.rcp:eclipse.feature$3.5.0.v20090519-9SA0FwxFv6x089WEf-TWh11#OSGi#source.feature.jar]
+INFO:  [start org.eclipse.equinox.p2.user.ui:eclipse.feature$1.1.0.v20090605-1440-7u6Fb3FbPbJP5MjJjZgifk#OSGi#source.manifest]
+INFO:  [end org.eclipse.equinox.p2.user.ui:eclipse.feature$1.1.0.v20090605-1440-7u6Fb3FbPbJP5MjJjZgifk#OSGi#source.manifest]
+INFO:  [start org.eclipse.equinox.p2.user.ui:eclipse.feature$1.1.0.v20090605-1440-7u6Fb3FbPbJP5MjJjZgifk#OSGi#source.feature.jar]
+INFO:  [end org.eclipse.equinox.p2.user.ui:eclipse.feature$1.1.0.v20090605-1440-7u6Fb3FbPbJP5MjJjZgifk#OSGi#source.feature.jar]
+INFO:  [start org.eclipse.buckminster.tutorial.rcpp2.feature:eclipse.feature$1.0.0#OSGi#source.manifest]
+INFO:  [end org.eclipse.buckminster.tutorial.rcpp2.feature:eclipse.feature$1.0.0#OSGi#source.manifest]
+INFO:  [start org.eclipse.buckminster.tutorial.rcpp2.feature:eclipse.feature$1.0.0#OSGi#source.feature.jar]
+INFO:  [end org.eclipse.buckminster.tutorial.rcpp2.feature:eclipse.feature$1.0.0#OSGi#source.feature.jar]
+INFO:  [start org.eclipse.equinox.executable:eclipse.feature$3.3.200.v20090521-1800-7M-Fm-FI3UouOe61h3BYGC#OSGi#source.manifest]
+INFO:  [end org.eclipse.equinox.executable:eclipse.feature$3.3.200.v20090521-1800-7M-Fm-FI3UouOe61h3BYGC#OSGi#source.manifest]
+INFO:  [start org.eclipse.equinox.executable:eclipse.feature$3.3.200.v20090521-1800-7M-Fm-FI3UouOe61h3BYGC#OSGi#source.feature.jar]
+INFO:  [end org.eclipse.equinox.executable:eclipse.feature$3.3.200.v20090521-1800-7M-Fm-FI3UouOe61h3BYGC#OSGi#source.feature.jar]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#source.manifest]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#source.manifest]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#source.feature.jar]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#source.feature.jar]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#copy.features]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#copy.features]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#copy.plugins]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#copy.plugins]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#site.p2]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#site.p2]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#create.product]
+[ant] /opt/eclipse/eclipse3.5RC4/eclipse/plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
+[ant] file:/var/lib/hudson/jobs/MailApp/workspace/buckminster.output/org.eclipse.buckminster.tutorial.mailapp.product.feature_1.0.0.null-eclipse.feature/site.p2/
+[ant] /var/lib/hudson/jobs/MailApp/workspace/buckminster.output/org.eclipse.buckminster.tutorial.mailapp.product.feature_1.0.0.null-eclipse.feature/MailApp
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#create.product]
+INFO:  [start org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#create.product.zip]
+INFO:  [end org.eclipse.buckminster.tutorial.mailapp.product.feature:eclipse.feature$1.0.0#OSGi#create.product.zip]
+Warning: file /var/lib/hudson/jobs/MailApp/workspace/plugins/org.eclipse.buckminster.tutorial.mailapp/src/org/eclipse/buckminster/tutorial/mailapp/NavigationView.java, line 43: ArrayList is a raw type. References to generic type ArrayList<E> should be parameterized
+Warning: file /var/lib/hudson/jobs/MailApp/workspace/plugins/org.eclipse.buckminster.tutorial.mailapp/src/org/eclipse/buckminster/tutorial/mailapp/NavigationView.java, line 57: Type safety: The method toArray(Object[]) belongs to the raw type ArrayList. References to generic type ArrayList<E> should be parameterized
+Warning: file /var/lib/hudson/jobs/MailApp/workspace/plugins/org.eclipse.buckminster.tutorial.mailapp: Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment.


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Re: Warnings Plugin: New Parser for Buckminster

Ulli Hafner-2
> Hi Ullrich,
>
> wow, that was fast :)

You are quite fast with your testcase, too:-)

>
> Is the attached test case sufficient?

Yes it is. Thanks (rev 19482).

I'll prepare a new release soon...

Ulli


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]