Menu

#1491 [core] CodeClimateRenderer: corrupt JSON output with real line breaks

PMD-5.5.0
closed
core (10)
PMD
3-Major
Bug
2016-06-25
2016-06-03
No

When using code climate output with XPath rules, then the "content/body" property contains a very long string and eventually also the XPath expression of the rule. However, the XPath expression might contain line breaks, which are not escaped in the output... hence creating a corrupt JSON file.

Corrupt example:

{"type":"issue","check_name":"CollapsibleIfStatements","description":"These nested if statements could be combined","content":{"body":"## CollapsibleIfStatements\n\nSince: PMD 3.1\n\nPriority: Medium\n\n[Categories](https://github.com/codeclimate/spec/blob/master/SPEC.md#categories): Style\n\n[Remediation Points](https://github.com/codeclimate/spec/blob/master/SPEC.md#remediation-points): 50000\n\nSometimes two consecutive `if` statements can be consolidated by separating their conditions with a boolean short-circuit operator.\n\n### Example:\n\n```java\n\n  \nvoid bar() {\n\tif (x) {\t\t\t// original implementation\n\t\tif (y) {\n\t\t\t// do stuff\n\t\t}\n\t}\n}\n\nvoid bar() {\n\tif (x && y) {\t\t// optimized implementation\n\t\t// do stuff\n\t}\n}\n \n      \n```  \n\n### [PMD properties](http://pmd.github.io/pmd-5.1.3/pmd-developer.html)\n\nName | Value | Description\n--- | --- | ---\nviolationSuppressRegex | null | Suppress violations with messages matching a regular expression\nviolationSuppressXPath | null | Suppress violations on nodes which match a given relative XPath expression.\nversion | 1.0 | XPath specification version\nxpath | 

//IfStatement[@Else='false']/Statement
 /IfStatement[@Else='false']
 |
//IfStatement[@Else='false']/Statement
 /Block[count(BlockStatement)=1]/BlockStatement
  /Statement/IfStatement[@Else='false']
             | XPath expression\n"},"categories":["Style"],"location":{"path":"/home/andreas/PMD/source/pmd-github/pmd-core/src/main/java/net/sourceforge/pmd/RuleSetFactory.java","lines":{"begin":617,"end":619}},"severity":"normal","remediation_points":50000}

Discussion

  • Andreas Dangel

    Andreas Dangel - 2016-06-08
     
  • Andreas Dangel

    Andreas Dangel - 2016-06-08
    • status: open --> closed
    • assigned_to: Andreas Dangel
     
  • Andreas Dangel

    Andreas Dangel - 2016-06-25
    • labels: --> core
    • summary: Code Climate JSON - corrupt output with real line breaks --> [core] CodeClimateRenderer: corrupt JSON output with real line breaks
     

Log in to post a comment.