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

CPPCheckParser does not parse auto closed <error/> tags #82

Closed
djpeinado opened this issue Feb 3, 2020 · 6 comments
Closed

CPPCheckParser does not parse auto closed <error/> tags #82

djpeinado opened this issue Feb 3, 2020 · 6 comments

Comments

@djpeinado
Copy link

CPPCheckParser.java

final List<String> errorChunks = getChunks(string, "<error", "</error>");

This code does not parse tags.

When I run cppcheck with --xml parameter, the output I get is <error/> and not <error></error>

@djpeinado
Copy link
Author

djpeinado commented Feb 3, 2020

Sample cppcheck output:

<?xml version="1.0" encoding="UTF-8"?>
<results>
    <error file="filename.cpp" line="49" id="variableScope" severity="style" msg="The scope of the variable &apos;softwareComponentsAreOk&apos; can be reduced. Warning: Be careful when fixing this message, especially when there are inner loops. Here is an example where cppcheck will write that the scope for &apos;i&apos; can be reduced:
void f(int x)
{
    int i = 0;
    if (x) {
        // it&apos;s safe to move &apos;int i = 0;&apos; here
        for (int n = 0; n &lt; 10; ++n) {
            // it is possible but not safe to move &apos;int i = 0;&apos; here
            do_something(&amp;i);
        }
    }
}
When you see this message it is always safe to reduce the variable scope 1 level."/>
</results>

tomasbjerre added a commit to tomasbjerre/violation-comments-to-bitbucket-cloud-command-line that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violation-comments-to-bitbucket-server-command-line that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violation-comments-to-github-command-line that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violation-comments-to-github-gradle-plugin that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violation-comments-to-github-maven-plugin that referenced this issue Feb 3, 2020
tomasbjerre added a commit to jenkinsci/violation-comments-to-github-plugin that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violation-comments-to-gitlab-command-line that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violation-comments-to-gitlab-gradle-plugin that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violation-comments-to-gitlab-maven-plugin that referenced this issue Feb 3, 2020
tomasbjerre added a commit to jenkinsci/violation-comments-to-gitlab-plugin that referenced this issue Feb 3, 2020
tomasbjerre added a commit to jenkinsci/violation-comments-to-stash-plugin that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violations-command-line that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violations-gradle-plugin that referenced this issue Feb 3, 2020
tomasbjerre added a commit to tomasbjerre/violations-maven-plugin that referenced this issue Feb 3, 2020
@tomasbjerre
Copy link
Owner

All the tools should have this fix now! Open issue again if not working.

@uhafner
Copy link
Contributor

uhafner commented Feb 6, 2020

This fix caused a regression in the warnings plugin, it breaks one of my test cases: jenkinsci/analysis-model#291

Seems that now some violations are reported twice: for the following file I get three violations per error now. With the previous release I got only two violations (and that seems to be correct).

<?xml version="1.0" encoding="UTF-8"?>
<results version="2">
  <cppcheck version="1.52"/>
  <error id="redundantAssignment" severity="style" msg="Variable &apos;it&apos; is reassigned a value before the old one has been used." verbose="Variable &apos;it&apos; is reassigned a value before the old one has been used." cwe="563">
    <location file0="apps\cloud_composer\src\point_selectors\rectangular_frustum_selector.cpp" file="apps\cloud_composer\src\point_selectors\rectangular_frustum_selector.cpp" line="53"/>
    <location file0="apps\cloud_composer\src\point_selectors\rectangular_frustum_selector.cpp" file="apps\cloud_composer\src\point_selectors\rectangular_frustum_selector.cpp" line="51"/>
    <symbol>it</symbol>
  </error>
  <error id="redundantAssignment" severity="style" msg="Variable &apos;that&apos; is reassigned a value before the old one has been used." verbose="Variable &apos;that&apos; is reassigned a value before the old one has been used." cwe="563">
    <location file0="apps\cloud_composer\src\point_selectors\rectangular_frustum_selector.cpp" file="that\cloud_composer\src\point_selectors\rectangular_frustum_selector.cpp" line="51"/>
    <location file0="apps\cloud_composer\src\point_selectors\rectangular_frustum_selector.cpp" file="that\cloud_composer\src\point_selectors\rectangular_frustum_selector.cpp" line="53"/>
    <symbol>that</symbol>
  </error>
</results>

tomasbjerre added a commit that referenced this issue Feb 6, 2020
@tomasbjerre
Copy link
Owner

I added a test case, and I do get 4 violations:
2b96ad7

@tomasbjerre
Copy link
Owner

@uhafner I add the result to a Set to get rid of duplicates:
https://github.com/tomasbjerre/violations-lib/blob/master/src/main/java/se/bjurr/violations/lib/reports/Parser.java#L108

I think that is why you get 6 results, and I get 4.

@uhafner
Copy link
Contributor

uhafner commented Feb 9, 2020

Ok, this was not required in 1.109. Nevertheless, since I am already storing all the issues in a set I can change that in my implementation quite easily (see jenkinsci/analysis-model@8258926). Thanks for the tip!

aakoch pushed a commit to aakoch/violation-comments-to-stash-plugin that referenced this issue Dec 12, 2020
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

No branches or pull requests

3 participants