Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for findbug xml output #614

Merged
merged 3 commits into from
Aug 21, 2020
Merged

Conversation

bferdinandus
Copy link

There where some problems with the findbugs xml. I was unable to have jenkins parse the xml file because the signature on the Method node was not valid.
Also the timestamp on the FindbugsSummary node was in the wrong format.

@TheRealAgentK
Copy link
Collaborator

I'm rather cautious of this change for 2 reasons:

  1. The current findbugs output parses fine with other CI systems like TeamCity and we want to avoid breaking anything to fix an unspecified problem with Jenkins.

  2. The output creation of the various XML formats is unfortunately quite intertwined and this change might (I don't know yet at this stage) break or alter other output formats.

It should not be merged without further investigation.

@TheRealAgentK
Copy link
Collaborator

@bferdinandus Could you please provide some additional info on the error you are getting with the current implementation of Findbug in CFLint in Jenkins?

@TheRealAgentK TheRealAgentK self-assigned this Jan 25, 2019
@bferdinandus
Copy link
Author

I have tried parsing the FindBugs file with the Findbugs plugin (old style, depricated) for Jenkins, the Warnings NG plugin (followup for the Findbugs plugin) for Jenkins, and the Findbugs plugin for Intellij IDEA. All three give the same errors.

I’ll first address the timestamp issue I found when parsing the Findbugs xml.

[FindBugs] [ERROR] Parsing of file 'C:\Program Files (x86)\Jenkins\workspace\CFLint test\CfLintfindbugsStyle.xml' failed due to an exception: [FindBugs] [ERROR] java.text.ParseException: Unparseable date: "1548751036" [FindBugs] [ERROR] at java.text.DateFormat.parse(Unknown Source) [FindBugs] [ERROR] at edu.umd.cs.findbugs.ProjectStats.setTimestamp(ProjectStats.java:158) [FindBugs] [ERROR] at edu.umd.cs.findbugs.SAXBugCollectionHandler.startElement(SAXBugCollectionHandler.java:323)
The “unparsable date” is the timestamp on the FindBugsSummary tag in the xml file. I have looked up the xsd file in the Findbugs repository on github, and noticed that hat specific attribute should be a string. bugcollection.xsd Line 375

In the java file ProjectStats.java Line 162 you can see the timestamp is parsed with the java function ‘SimpleDateFormat’ with this string as the date format
private static final String TIMESTAMP_FORMAT = "EEE, d MMM yyyy HH:mm:ss Z";

That’s why I added the format date function so the XSL transformation can print the right date format at that one specific location.

Next problem I found was the signature attribute on the method node. According to the xsd bugcollection.xsd Line 127 the signature attribute is a required string. So, it cannot be empty. If it is empty the followin error occurs on parsing the Findbugs xml:

java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(Unknown Source) at edu.umd.cs.findbugs.ba.SignatureConverter.getFirst(SignatureConverter.java:59) at edu.umd.cs.findbugs.MethodAnnotation.getNameInClass(MethodAnnotation.java:408)

After searching throug the findbugs library and analyzing the file SignatureConverter.java It looks like the signature must at least contain parenthesis () and a letter after that determining the return type of the function. So ()V is the most basic. V stands for ‘void’

@bferdinandus
Copy link
Author

@TheRealAgentK any news about the progress on this pullrequest?

@bferdinandus
Copy link
Author

Any news on the progress of this pullrequest?

@ryaneberly
Copy link
Contributor

@bferdinandus . Thanks for your detailed analysis, and contribution! I apologize for moving slowly on this one.

I agree with all of your modifications -- even the timestamp one. Findbugs seems to choose odd formats for timestamps, and is not consistent even within its own xml format! I confirmed the latest version of spot bugs does use the format you propose on the FindBugsSummary tag.

@ryaneberly ryaneberly merged commit feb924c into cflint:dev Aug 21, 2020
@bferdinandus bferdinandus deleted the findbug-xml-format branch September 10, 2020 11:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants