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

CxxReportSensor.java: file not found for issue #693

Closed
BobSilent opened this issue Nov 30, 2015 · 8 comments
Closed

CxxReportSensor.java: file not found for issue #693

BobSilent opened this issue Nov 30, 2015 · 8 comments
Assignees
Milestone

Comments

@BobSilent
Copy link
Contributor

Hi,

the visualStudio c++ compiler writes the compiler warnings without absolute path information into the log file, if the source file (which has an issue) belongs to my vcxproj.
Example

  aaa.cpp
  bbb.cpp
  ccc.cpp
C:\FULLPATH_TO_GLOBAL_INCLUDE\Include\ddd.h(xx): warning C4239: nonstandard extension used : 'argument' : conversion from 'CString' to 'CString &' (ccc.cpp)
          A non-const reference may only be bound to an lvalue
ccc.cpp(yyy): warning C4239: nonstandard extension used : 'argument' : conversion from 'CString' to 'CString &'
          A non-const reference may only be bound to an lvalue

unfortunately the source file ccc.cpp is not found, as in
CxxReportSensor.java (sonar-cxx-plugin/src/main/java/org/sonar/plugins/cxx/utils/CxxReportSensor.java)

  private void saveViolation(Project project, SensorContext context, String ruleRepoKey,
    String filename, String line, String ruleId, String msg) {
    Issuable issuable = null;
    int lineNr = 0;
    // handles file="" situation -- file level
    if ((filename != null) && (filename.length() > 0)) {
      String root = reactor.getRoot().getBaseDir().getAbsolutePath();

you are using

      String root = reactor.getRoot().getBaseDir().getAbsolutePath();

for resolving the root directory,
if I change it to

      String root = fs.baseDir().getAbsolutePath();

everything can be resolved.
also other sensors, e.g. java use fs.baseDir
sonar-java/java-surefire/src/main/java/org/sonar/plugins/surefire/api/SurefireUtils.java
sonar-java/java-jacoco/src/main/java/org/sonar/plugins/jacoco/JaCoCoOverallSensor.java

Some other side aspects: i am using the following directory structure

\sonar-project.properties (*)
├───module1
│       module1.vcxproj (**)
│       sonar-project.properties
│
├───module2
│       module2.vcxproj
│       sonar-project.properties
│
├───module3
│       module3.vcxproj
│       sonar-project.properties
│
└───module4...

() one root project properties
(
*) module properties, in parallel to the vcxproj

reactor.getRoot().getBaseDir().getAbsolutePath() is always "" same as location of ()
fs.baseDir().getAbsolutePath() is e.g. "\module1" location of module1 directory (
*)

Why do you use "reactor.getRoot().getBaseDir()"?
Can it be changed to "fs.baseDir()"

@jmecosta
Copy link
Member

@Bertk you use this kind of module structure, i tough you had no issues with this. @guwirth perhaps we should use the same approach as the report lookup, use reactor to lookup from root of the project and if not found search using the fs.baseDir to get to root of the module.

@BobSilent i dont think using your suggestion will cover all scenarios we support, you can try to make a pull request and see if the integration tests pass, pretty sure they dont

@guwirth
Copy link
Collaborator

guwirth commented Nov 30, 2015

On this page https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Path-and-path-separator-issues is also a description how MultiModule setup should work. I don't use it so I have no experience with it.

@Bertk
Copy link
Contributor

Bertk commented Dec 1, 2015

Please use 'FC' compiler option (https://msdn.microsoft.com/en-us/library/19z1t1wy.aspx) which creates full path information in the VC log files. We use the multi module configuration and use identical names in several projects which is ambiguous without the full path.

@guwirth
Copy link
Collaborator

guwirth commented Dec 1, 2015

,reactor.getRoot().getBaseDir().getAbsolutePath() is always "" same as location of ()
fs.baseDir().getAbsolutePath() is e.g. "\module1" location of module1 directory (*) Why do you use "reactor.getRoot().getBaseDir()"? Can it be changed to "fs.baseDir()"

My feeling is also that fs.baseDir().getAbsolutePath() is right?

@Bertk
Copy link
Contributor

Bertk commented Dec 2, 2015

Do we have a PR? I want to test it and maybe this might also be useful for #509.
Today I can only create the issues from reports but the "Dependency Structure Matrix" was not available.
There might be also an impact on MSBuild runner or the deprecated VS Solution bootstrapper plug-in which we should avoid.

@jmecosta
Copy link
Member

jmecosta commented Dec 2, 2015

Can the multi module sample we have in integrations test be used to check
this?

On Wed, Dec 2, 2015, 18:12 Bert [email protected] wrote:

Do we have a PR? I want to test it and maybe this might also be useful for
#509 #509.
Today I can only create the issues from reports but the "Dependency
Structure Matrix" was not available.
There might be also an impact on MSBuild runner or the deprecated VS
Solution bootstrapper plug-in which we should avoid.


Reply to this email directly or view it on GitHub
#693 (comment)
.

@guwirth
Copy link
Collaborator

guwirth commented Dec 3, 2015

@ALL see test with #695 and comments there

@guwirth guwirth added this to the M 0.9.5 milestone Jan 16, 2016
@guwirth guwirth self-assigned this Jan 16, 2016
@guwirth
Copy link
Collaborator

guwirth commented Jan 16, 2016

please try again with 0.9.5:

@guwirth guwirth closed this as completed Jan 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants