sonar fxcop results not displayed

726 Views Asked by At

I'm trying to use Sonar on some ASP.Net applications. I have installed Sonar and configured C# environment, and I get this working...except for FXcop (Code Analysis).

I followed the official documentation :

  • sonar-runner.bat is ok
  • FXCop path is well configured
  • Sonnar-runner launches FXcop (12.0) correctly
  • FXCop builds the "fxcop-report.xml" in the .sonar directory of the project
  • This file contains some "issues" that I should see in Sonarqube
  • FXCop exit with 1024 code, wich seems ok for sonar-runner
  • sonar-runner execution seems to be fine all along : "ANALYSIS SUCCESSFUL"... Then "EXECUTION SUCCESS"

My default Quality rules are "only" the FXCop ones.

But when I'm connecting to sonarqube, I have "0" defaults for my projects. I mean, I would really want to have 0 defaults, but this is not the reality.

I've been searching al lot, and I've seen on an official forum saying that the issues elements in the reports should have "path" and "file" attributes to get it working, and I'm in that case :

<Member Name="#TypeDeclar()" Kind="Method" Static="False" Accessibility="Private" ExternallyVisible="False">
       <Messages>
        <Message TypeName="Dispose objects before losing scope" Category="Microsoft.Reliability" CheckId="CA2000" Status="Active" Created="2015-01-19 13:37:17Z" FixCategory="DependsOnFix" BreaksBuild="True">
         <Issue Name="ExceptionEdge" Certainty="75" Level="Warning" Path="c:\Projects\ProjectA" File="WebEdition.ascx.cs" Line="71">In method 'WebEdition.TypeDeclar()', object 'sqlcmd' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'sqlcmd' before all references to it are out of scope.</Issue>
         <Issue Name="ExceptionEdge" Certainty="75" Level="Warning" Path="c:\Projects\ProjectA" File="WebEdition.ascx.cs" Line="69">In method 'WebEdition.TypeDeclar()', object 'sqlconn' is not disposed along all exception paths. Call System.IDisposable.Dispose on object 'sqlconn' before all references to it are out of scope.</Issue>
        </Message>
        <Message TypeName="Do not dispose objects multiple times" Category="Microsoft.Usage" CheckId="CA2202" Status="Active" Created="2015-01-19 13:37:17Z" FixCategory="DependsOnFix" BreaksBuild="True">
         <Issue Certainty="75" Level="Warning" Path="c:\Projects\ProjectA" File="WebEdition.ascx.cs" Line="92">Object 'sqlconn' can be disposed more than once in method 'WebEdition.TypeDeclar()'. To avoid generating a System.ObjectDisposedException you should not call Dispose more than one time on an object.: Lines: 92</Issue>
        </Message>
       </Messages>

Hope someone notice someting I miss !!! Thanks.

1

There are 1 best solutions below

1
On

I finally found the issue : it was because the absolute path of my code source on my server, where I execute Sonar, was not equal to the one on my development computer :

Dev computer

C:\Projects\ProjectA....

Server :

C:\ContinuousIntegration\Dotnet\Projects\ProjectA....

Sonar was unable to find the files, because it was looking for with the "dev" absolute path.

I've seen this executing "sonar-runner -X", and reading all the log...

Hope it will helps someone ;)