stg-tud / MUBench

Other
54 stars 30 forks source link

Warning message while publishing the findings of Findbugs to reviewsite #407

Closed VidyashreeN closed 6 years ago

VidyashreeN commented 6 years ago

It might be that MUBenchPipe cannot find the location that Findbugs report to extract a snippet. [WARNING] Could not extract snippet for 'loadJellyProperties()' from 'org/apache/commons/jelly/Jelly.java': no matches

salsolatragus commented 6 years ago

I need more information to help you with this.

/CC @akwick

akwick commented 6 years ago

@VidyashreeN if you use an issue, please try to answer here rather than in an email. It'll help to have an overview [IMO] The answer uses some content of an E-Mail @VidyashreeN sent to @salsolatragus and me.

The error message occurs in Experiment 2 and 3.

Experiment 2

Snippet for Experiment 2

I have looked up the highlighted path for Experiment 2. The path is the location which is reported by Findbugs (see in the above comment).

package org.uberfire.server;
[...]
private String getFileContent( final String fileName ) {

At the first glance, the locations are equal. I have written a test (MethodExtractoTest.java) which should test whether the method can be found:

@Test      
    public void verifyIssue407() throws Exception {
        testFindsMethod("public class UberfireServlet extends HttpServlet {\n"
                        + "     private String getFileContent( final String fileName ) {\n"
                        + "     try { \n"
                        + "         return getTemplateContent( new BufferedInputStream( new FileInputStream( fileName ) ) );\n"
                        + "         } catch ( FileNotFoundException e ) {\n"
                        + "          throw new IllegalStateException( \"Template file not found.\", e )\n"
                        + "     }\n"
                        + " }\n"
                        + "}\n",
                        "getFileContent(String)",
                        "   private String getFileContent( final String fileName ) {\n"
                        + "     try { \n"
                        + "         return getTemplateContent( new BufferedInputStream( new FileInputStream( fileName ) ) );\n"
                        + "         } catch ( FileNotFoundException e ) {\n"
                        + "          throw new IllegalStateException( \"Template file not found.\", e )\n"
                        + "     }");
    }

This test fails (mvn verify -f mubench.utils/pom.xml):

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running de.tu_darmstadt.stg.mubench.utils.MethodExtractorTest
Tests run: 37, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.644 sec <<< FAILURE! - in de.tu_darmstadt.stg.mubench.utils.MethodExtractorTest
verifyIssue407(de.tu_darmstadt.stg.mubench.utils.MethodExtractorTest)  Time elapsed: 0.061 sec  <<< FAILURE!
java.lang.AssertionError: No method found.
        at org.junit.Assert.fail(Assert.java:88)
        at de.tu_darmstadt.stg.mubench.utils.MethodExtractorTest.testFindsMethod(MethodExtractorTest.java:468)
        at de.tu_darmstadt.stg.mubench.utils.MethodExtractorTest.verifyIssue407(MethodExtractorTest.java:440)

Results :

Failed tests:
  MethodExtractorTest.verifyIssue407:440->testFindsMethod:468 No method found.

Tests run: 37, Failures: 1, Errors: 0, Skipped: 0

To point the problem a bit more down, I have created a simplified version.

    @Test
    public void verifyIssue407Simplified() throws Exception {
        testFindsMethod("public class UberfireServlet extends HttpServlet {\n"
                        + "     private String getFileContent( final String fileName ) {}\n"
                        + "}\n",
                "getFileContent(String)",
                "   private String getFileContent( final String fileName ) {}");
    }

which passes.

This indicates a problem or that I have misused the test. I will try to debug it later this week or next week.

Experiment 3

Snippet for Experiment 3

This warning is produced with the information from your misuse.yml. I have inspected your corresponding misuse.yml files. The misuse.yml matches at the first glance to the warning.

Inspecting the corresponding file of the projects leads to:


package org.uberfire.server;
[...]
public class FileDownloadServlet
  extends HttpServlet {
[...]

  protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

This matches with the file and method reported in your misuse.yml

Currently, I assume that both warnings are caused by the same issue but I am not 100% sure.

salsolatragus commented 6 years ago

@akwick thanks for your debugging! I think you understood the test alright. The problem is a syntax error in the code (missing semicolon after the throw statement), which leads to JavaParser being unable to parse the file. This syntax error is not in the original file you linked, though. After fixing it, everything works as expected.

I rather assume that there is a problem with the project source paths. FindBugs reports relative source-file paths, e.g., org/uberfire/server/UberfireServlet.java. Therefore, MUBench searches for this file in the project source directories specified in the version.yml file (src key). In the debugging case, src is uberfire-server/src/main/java, which seems to be correct.

@VidyashreeN can you please verify via ./mubench browse that the file /mubench/checkouts/uberfire/0.3.1/build/uberfire-server/src/main/java/org/uberfire/server/UberfireServlet.java exists? If not, what does the path to UberfileServlet.java actually look like? The difference might help me identify the problem.

VidyashreeN commented 6 years ago

@salsolatragus @akwick Thank you for your valuable inputs. I verified through ./mubench browse and Yes, the file /mubench/checkouts/uberfire/0.3.1/build/uberfire-server/src/main/java/org/uberfire/server/UberfireServlet.java exists.

salsolatragus commented 6 years ago

There was indeed a bug in Findbugs' reporting. It reported the line numbers and rank of findings as strings, instead of integers, which led to a type-conversion error in the pipeline. I fixed this (MUBench/FindBugs@4ce3045af786de488b652de75bbc6a4d98fd3ead) and updated the detector (59fccb93399f67392bcb7ad6019cf18e7761e626).

@VidyashreeN Please update MUBench and rerun Findbugs (--force-detect). The snippet extraction works for me now.

VidyashreeN commented 6 years ago

@salsolatragus @akwick I rerun Findbugs with the updated version, the warning does not exist any more. Thank you !!