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

Issue56510 #154

Merged
merged 5 commits into from
Apr 26, 2019
Merged

Issue56510 #154

merged 5 commits into from
Apr 26, 2019

Conversation

JustABunchOfCode
Copy link
Contributor

Add a custom XML-Parser, which was inspired by the Eclipse XML parser.

https://issues.jenkins-ci.org/browse/JENKINS-56510

@codecov
Copy link

codecov bot commented Apr 10, 2019

Codecov Report

Merging #154 into master will decrease coverage by 0.09%.
The diff coverage is 96.61%.

Impacted file tree graph

@@             Coverage Diff             @@
##             master     #154     +/-   ##
===========================================
- Coverage     88.47%   88.38%   -0.1%     
- Complexity     1230     1260     +30     
===========================================
  Files           158      160      +2     
  Lines          3922     4045    +123     
  Branches        424      438     +14     
===========================================
+ Hits           3470     3575    +105     
- Misses          296      314     +18     
  Partials        156      156
Impacted Files Coverage Δ Complexity Δ
src/main/java/edu/hm/hafner/analysis/Severity.java 96.42% <100%> (+0.13%) 27 <0> (+1) ⬆️
.../java/edu/hm/hafner/analysis/parser/XmlParser.java 96.49% <96.49%> (ø) 11 <11> (?)
...a/edu/hm/hafner/analysis/RegexpDocumentParser.java 0% <0%> (-100%) 0% <0%> (-2%)
...main/java/edu/hm/hafner/analysis/RegexpParser.java 0% <0%> (-80%) 0% <0%> (-5%)
...du/hm/hafner/analysis/parser/GnuFortranParser.java 91.17% <0%> (-8.83%) 9% <0%> (+5%)
.../edu/hm/hafner/analysis/parser/DrMemoryParser.java 76.47% <0%> (-2.11%) 15% <0%> (+2%)
...java/edu/hm/hafner/analysis/FileReaderFactory.java 78.57% <0%> (-1.43%) 9% <0%> (-2%)
...a/edu/hm/hafner/analysis/parser/pmd/PmdParser.java 87.01% <0%> (-0.75%) 14% <0%> (+4%)
...du/hm/hafner/analysis/parser/NagFortranParser.java 100% <0%> (ø) 6% <0%> (-1%) ⬇️
...in/java/edu/hm/hafner/analysis/parser/pmd/Pmd.java 100% <0%> (ø) 5% <0%> (+2%) ⬆️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f2b822e...62ce6f3. Read the comment docs.

@uhafner
Copy link
Member

uhafner commented Apr 15, 2019

Wasn't the idea to reuse the code in the warnings-plugin and the serialization of XStream?

@JustABunchOfCode
Copy link
Contributor Author

The reason why i didn't reuse the code is: "Adding dependency on module 'warnings-ng' will introduce circular dependency between modules 'analysis-model' and 'warnings-ng'. "
Should I still reuse the code from warnings_ng?
Or should I only replace XPath (used by the EclipseXMLParser) with XStream?

@uhafner
Copy link
Member

uhafner commented Apr 16, 2019

Well, actually the idea was to place the parser class into the module warnings-ng in order to simply things. But now that you have done all the work it is fine to leave it here. Typically converting a bean to an XML or JSON file is just much simpler...

*
* @author Raphael Furch
*/
public class DefaultXmlMapper extends HashMap<String, String> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this class, keep it simple as possible.

*
* @author Raphael Furch
*/
public class CustomXmlMapper extends HashMap<String, String> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this class.

/**
* Identifier for file name.
*/
public static final String FILE_NAME = "fileName";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make all constants private and remove comment.


/**
* Create a new ReportParser object.
* @param root = Path in xml file to issue collection.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param root path in ...

No =

Report report = new Report();

NodeList issues = (NodeList)path.evaluate(getXmlIssueRoot(), doc, XPathConstants.NODESET);
// Read all issues.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comment


/**
* Read a value from XML and set a default value if its null.
* @param path = xpath.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No = and reformat with IntelliJ auto format

* @return value or default value.
* @throws XPathExpressionException error.
*/
private String notNullableRead(final XPath path, final String value, final Element issue) throws XPathExpressionException {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is save to return null here as the IssueBuilder instance correctly handles null values.

.hasReference("Reference 1")
.hasFingerprint("Fingerprint 1")
.hasAdditionalProperties("Property 1, Property 2");

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use auto format, just one blank line is enough

}

@Test
void shouldParseWithCustomPathAndMapper() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this test

}

@Test
void shouldThrowParserException() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add one test that shows that the parser still produces a list of issues if just one XML tag contains wrong values?

@uhafner uhafner merged commit 62ce6f3 into jenkinsci:master Apr 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants