violations-plugin icon indicating copy to clipboard operation
violations-plugin copied to clipboard

Feature Request: cppcheck integration

Open bufferoverflow opened this issue 11 years ago • 3 comments

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.

bufferoverflow avatar Sep 17 '14 08:09 bufferoverflow

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

tomasbjerre avatar Jun 14 '15 19:06 tomasbjerre

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

bufferoverflow avatar Jun 14 '15 20:06 bufferoverflow

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>

tomasbjerre avatar Jun 14 '15 20:06 tomasbjerre