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

SampleProject2 sample does not report cppcheck 1.63 errors in SonarQube 4.2 #191

Closed
jlemetay opened this issue Apr 30, 2014 · 6 comments
Closed

Comments

@jlemetay
Copy link

Hello,

I should miss something important because I don't manage to run the SampleProject2 sample provided by the Cxx plugin.

Environment:

  • SonarQube Version 4.2
  • SonarQube Runner 2.3
  • Database MySQL 5.1.69
  • Linux version 2.6.32-279.22.1.el6.x86_64
  • java version "1.7.0_45"
  • Cppcheck 1.63

Cxx plugin 2014-04-18 (https://github.com/wenns/sonar-cxx/archive/631e2e7a601540375bee7d71a849c8dcf884d206.zip)

For testing purpose, I have copied the sonar-cxx-plugin/src/samples/SampleProject2 into
/data/sonarqube/cxx/SampleProject2. Then I have modified in the
sonar-project.properties file the "sonar.cxx.include_directories" property
in order that Cxx can find the include files in my configuration. THIS WORKS!

During "make sonar", cppcheck generates correctly an XML report :

cppcheck -v --enable=all --xml -Isrc src 2> /data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml
It detects 11 errors

1 |?xml version="1.0" encoding="UTF-8"?|
2 |results|
3 |error file="src/lib/component1.cc" line="17" id="unusedVariable" severity="style" msg="Unused variable: x"/|
4 |error file="src/lib/component1.cc" line="37" id="unreadVariable" severity="style" msg="Variable 'i' is assigned a value that is never used."/|
5 |error file="src/lib/component1.cc" line="47" id="deallocDealloc" severity="error" msg="Deallocating a deallocated pointer: ip"/|
6 |error file="src/lib/component1.cc" line="47" id="doubleFree" severity="error" msg="Memory pointed to by 'ip' is freed twice."/|
7 |error file="src/lib/component1.cc" line="32" id="uninitvar" severity="error" msg="Uninitialized variable: a"/|
8 |error file="src/lib/component2.cc" line="16" id="unusedVariable" severity="style" msg="Unused variable: x"/|
9 |error file="src/lib/component2.cc" line="36" id="unreadVariable" severity="style" msg="Variable 'i' is assigned a value that is never used."/|
10 |error file="src/lib/component2.cc" line="46" id="deallocDealloc" severity="error" msg="Deallocating a deallocated pointer: ip"/|
11 |error file="src/lib/component2.cc" line="46" id="doubleFree" severity="error" msg="Memory pointed to by 'ip' is freed twice."/|
12 |error file="src/lib/component2.cc" line="31" id="uninitvar" severity="error" msg="Uninitialized variable: a"/|
13 |error file="src/lib/component1.cc" line="24" id="unusedFunction" severity="style" msg="The function 'do_valgrind_errors' is never used."/|
14 |/results|

BUT during sonar-runner analysis, the CxxCppCheckSensor encounters a problem:

INFO - Sensor CxxCppCheckSensor...
INFO - Processing report '/data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml'
INFO - cppcheck V2 - Parsing report '/data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml'
INFO - cppcheck V1 - Parsing :report '/data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml'
WARN - Cannot find the file 'src/lib/component1.cc', skipping violations
WARN - Cannot find the file 'src/lib/component2.cc', skipping violations
INFO - Added report '/data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml' (parsed by: org.sonar.plugins.cxx.cppcheck.CppcheckParserV1@4d4908d4)
INFO - Sensor CxxCppCheckSensor done: 16 ms

The files 'src/lib/component1.cc' and 'src/lib/component2.cc', which are
available and readable, are not found! So no cppcheck errors are reported in
the Sample project in the sonarqube dashboard.

What is wrong here?

@jmecosta
Copy link
Member

You need ./ in each file. So ./src/

See #102 it should already be fixed in head
On Apr 30, 2014 12:18 PM, "jlemetay" notifications@github.com wrote:

Hello,

I should miss something important because I don't manage to run the
SampleProject2 sample provided by the Cxx plugin.

Environment:

  • SonarQube Version 4.2
  • SonarQube Runner 2.3
  • Database MySQL 5.1.69
  • Linux version 2.6.32-279.22.1.el6.x86_64
  • java version "1.7.0_45"
  • Cppcheck 1.63

Cxx plugin 2014-04-18 (
https://github.com/wenns/sonar-cxx/archive/631e2e7a601540375bee7d71a849c8dcf884d206.zip
)

For testing purpose, I have copied the
sonar-cxx-plugin/src/samples/SampleProject2 into
/data/sonarqube/cxx/SampleProject2. Then I have modified in the
sonar-project.properties file the "sonar.cxx.include_directories" property
in order that Cxx can find the include files in my configuration. THIS
WORKS!

During "make sonar", cppcheck generates correctly an XML report :

cppcheck -v --enable=all --xml -Isrc src 2>
/data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml
It detects 11 errors

1 |?xml version="1.0" encoding="UTF-8"?|
2 |results|
3 |error file="src/lib/component1.cc" line="17" id="unusedVariable"
severity="style" msg="Unused variable: x"/|
4 |error file="src/lib/component1.cc" line="37" id="unreadVariable"
severity="style" msg="Variable 'i' is assigned a value that is never
used."/|
5 |error file="src/lib/component1.cc" line="47" id="deallocDealloc"
severity="error" msg="Deallocating a deallocated pointer: ip"/|
6 |error file="src/lib/component1.cc" line="47" id="doubleFree"
severity="error" msg="Memory pointed to by 'ip' is freed twice."/|
7 |error file="src/lib/component1.cc" line="32" id="uninitvar"
severity="error" msg="Uninitialized variable: a"/|
8 |error file="src/lib/component2.cc" line="16" id="unusedVariable"
severity="style" msg="Unused variable: x"/|
9 |error file="src/lib/component2.cc" line="36" id="unreadVariable"
severity="style" msg="Variable 'i' is assigned a value that is never
used."/|
10 |error file="src/lib/component2.cc" line="46" id="deallocDealloc"
severity="error" msg="Deallocating a deallocated pointer: ip"/|
11 |error file="src/lib/component2.cc" line="46" id="doubleFree"
severity="error" msg="Memory pointed to by 'ip' is freed twice."/|
12 |error file="src/lib/component2.cc" line="31" id="uninitvar"
severity="error" msg="Uninitialized variable: a"/|
13 |error file="src/lib/component1.cc" line="24" id="unusedFunction"
severity="style" msg="The function 'do_valgrind_errors' is never used."/|
14 |/results|

BUT during sonar-runner analysis, the CxxCppCheckSensor encounters a
problem:

INFO - Sensor CxxCppCheckSensor...
INFO - Processing report
'/data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml'
INFO - cppcheck V2 - Parsing report
'/data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml'
INFO - cppcheck V1 - Parsing :report
'/data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml'
WARN - Cannot find the file 'src/lib/component1.cc', skipping violations
WARN - Cannot find the file 'src/lib/component2.cc', skipping violations
INFO - Added report
'/data/sonarqube/cxx/SampleProject2/build/cppcheck-report.xml' (parsed by:
org.sonar.plugins.cxx.cppcheck.CppcheckParserV1@4d4908dhttps://github.com/org.sonar.plugins.cxx.cppcheck.CppcheckParserV1/sonar-cxx/commit/4d4908d4
)
INFO - Sensor CxxCppCheckSensor done: 16 ms

The files 'src/lib/component1.cc' and 'src/lib/component2.cc', which are
available and readable, are not found! So no cppcheck errors are reported
in
the Sample project in the sonarqube dashboard.

What is wrong here?


Reply to this email directly or view it on GitHubhttps://github.com//issues/191
.

@jlemetay
Copy link
Author

After modification of the generated cppcheck XML report as indicated, the sonar-runner analysis report cppcheck reports effectively.

Thanks for the reference. I knew that I had missed something.

Maybe, a doc. or script in the SampleProject2, should be helpfull because in the current state it does not work completely automatically.

Thank you.

@jmecosta
Copy link
Member

If you get latest and compile, this should be fix. @wenns made the fix 2 days ago. Do you mind trying it?

@jlemetay
Copy link
Author

Ok, I am going to try it.

@jlemetay
Copy link
Author

With the latest delivery, I confirm that the SampleProject2 passes automatically. There is no need to modify cppcheck XML report.

Bravo.

@jmecosta
Copy link
Member

great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants