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

Feature Request: cppcheck integration #54

Open
bufferoverflow opened this issue Sep 17, 2014 · 3 comments
Open

Feature Request: cppcheck integration #54

bufferoverflow opened this issue Sep 17, 2014 · 3 comments

Comments

@bufferoverflow
Copy link

Would be nice to have an integration of cppcheck within Violations-Plugin.
Today there is a seperate plugin: https://wiki.jenkins-ci.org/display/JENKINS/Cppcheck+Plugin
to visualize details, however having cppcheck within the violations graph would be great.

@tomasbjerre
Copy link
Contributor

Do you have a sample report that we can use when creating a parser?

@bufferoverflow
Copy link
Author

I can't upload a xml file here(only images are supported), but you can do this:

git clone https://github.com/u-boot/u-boot.git && cd u-boot
cppcheck --quiet --enable=all --force --inline-suppr --xml --xml-version=2 . 2> cppcheck-result.xml

all the best!
-roger

@tomasbjerre
Copy link
Contributor

Nice, I'll paste some of it here to use it later.

<?xml version="1.0" encoding="UTF-8"?>
<results version="2">
  <cppcheck version="1.52"/>
  <errors>
  <error id="variableScope" severity="style" msg="The scope of the variable 'i' can be reduced" verbose="The scope of the variable 'i' can be reduced. Warning: It can be unsafe to fix this message. Be careful. Especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:&#xa;void f(int x)&#xa;{&#xa;    int i = 0;&#xa;    if (x) {&#xa;        // it's safe to move 'int i = 0' here&#xa;        for (int n = 0; n &lt; 10; ++n) {&#xa;            // it is possible but not safe to move 'int i = 0' here&#xa;            do_something(&amp;i);&#xa;        }&#xa;    }&#xa;}&#xa;When you see this message it is always safe to reduce the variable scope 1 level.">
    <location file="api.c" line="498"/>
  </error>
  <error id="variableScope" severity="style" msg="The scope of the variable 'n' can be reduced" verbose="The scope of the variable 'n' can be reduced. Warning: It can be unsafe to fix this message. Be careful. Especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:&#xa;void f(int x)&#xa;{&#xa;    int i = 0;&#xa;    if (x) {&#xa;        // it's safe to move 'int i = 0' here&#xa;        for (int n = 0; n &lt; 10; ++n) {&#xa;            // it is possible but not safe to move 'int i = 0' here&#xa;            do_something(&amp;i);&#xa;        }&#xa;    }&#xa;}&#xa;When you see this message it is always safe to reduce the variable scope 1 level.">
    <location file="api.c" line="498"/>
  </error>
  <error id="variableScope" severity="style" msg="The scope of the variable 'i' can be reduced" verbose="The scope of the variable 'i' can be reduced. Warning: It can be unsafe to fix this message. Be careful. Especially when there are inner loops. Here is an example where cppcheck will write that the scope for 'i' can be reduced:&#xa;void f(int x)&#xa;{&#xa;    int i = 0;&#xa;    if (x) {&#xa;        // it's safe to move 'int i = 0' here&#xa;        for (int n = 0; n &lt; 10; ++n) {&#xa;            // it is possible but not safe to move 'int i = 0' here&#xa;            do_something(&amp;i);&#xa;        }&#xa;    }&#xa;}&#xa;When you see this message it is always safe to reduce the variable scope 1 level.">
    <location file="api_storage.c" line="104"/>
  </error>
  </errors>
</results>

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

2 participants