GregBartlett / sonar-resharper

MIT License
9 stars 21 forks source link

R# issues are not imported when analyzing in preview mode (SONARRSHPR-22) #19

Open christophelevis opened 8 years ago

christophelevis commented 8 years ago

The issue in short: When analysis is run in preview mode, R# issues are not included in the html reports.

Details: I'm running an analysis in preview mode and note that this analysis has not been run in analysis mode so SQ server doesn't know about this project (I don't if this is the root cause though).

    /k:"nsp:codequalitysample" ^
    /n:"Code Quality Sample" ^
    /v:"1.0" ^
    /d:sonar.resharper.cs.reportPath="%CD%\rir.xml" ^
    /d:sonar.resharper.solutionFile="%CD%\CodeQualitySample.sln" ^
    /d:sonar.analysis.mode=preview ^
    /d:sonar.issuesReport.html.enable=true ^

In this situation R# plugin skips all resharper issues with below messages (highlighted is a message I added to plugin code.).

INFO  - Sensor org.sonar.plugins.resharper.CSharpReSharperProvider$CSharpReSharperSensor
INFO  - Parsing ReSharper report: C:\Temp\SQAnalysis\SampleProject.7\ganesanr-financialapp-ganesanr-cc779ad9022f\rir.xml
INFO  - reSharperConf.languageKey()=cs;inputFile=null
INFO  - Skipping the ReSharper issue at line 17 whose file "C:\Temp\SQAnalysis\SampleProject.7\fapp\TPLTest\Program.cs" is not in SonarQube.
INFO  - reSharperConf.languageKey()=cs;inputFile=null
INFO  - Skipping the ReSharper issue at line 18 whose file "C:\Temp\SQAnalysis\SampleProject.7\fapp\TPLTest\Program.cs" is not in SonarQube.
INFO  - reSharperConf.languageKey()=cs;inputFile=null
INFO  - Skipping the ReSharper issue at line 19 whose file "C:\Temp\SQAnalysis\SampleProject.7\fapp\TPLTest\Properties\AssemblyInfo.cs" is not in SonarQube.
INFO  - Sensor org.sonar.plugins.resharper.CSharpReSharperProvider$CSharpReSharperSensor (done) | time=75ms

I tried modifying (shown below; ReSharperSensor.java around line 140) file system predicate but still it is not working (I must add that I'm no Java expert).

InputFile inputFile = fileSystem.inputFile(
  fileSystem.predicates().and(
          //Sonar Analysis is being run in a temporary path; AbsolutePath will never be the same
    //fileSystem.predicates().hasAbsolutePath(file.getAbsolutePath()),
          fileSystem.predicates().hasPath(file.getPath()),
    fileSystem.predicates().hasType(InputFile.Type.MAIN)));
if (inputFile != null) {
  LOG.info("reSharperConf.languageKey()=" + reSharperConf.languageKey() + ";inputFile.language()=" + inputFile.language());
}
else {
  LOG.info("reSharperConf.languageKey()=" + reSharperConf.languageKey() + ";inputFile=null");
}