C# FxCop Plugin not able to import issues from autogenerated code and non .cs files

263 views
Skip to first unread message

Shrinath Gupta

unread,
Jun 4, 2015, 4:47:13 AM6/4/15
to sona...@googlegroups.com

Hello,

Why "sonar-csharp-plugin-3.3.jar" plug-in is not able to import issues from autogenerated C# source code .g..cs files (the .cs file having "dot g dot" somewhere) and also from like .xaml ( non .cs files) file


Skipping the FxCop issue at line 429 whose file "d:\K\Sources\Debug\xyz.g.cs" is not in SonarQube.

Skipping the FxCop issue at line 386 whose file "d:\Ak\ws\tfs\View\TestsView.xaml" is not in SonarQube.

Pls. note that:

1) I have checked sonarqube configuration it is correct. 2) Issues from all other .cs files are perferctly getting imported.

anybody observed this behaviour?

Pls. help me here.

imsenthi...@gmail.com

unread,
Jul 10, 2015, 10:34:26 AM7/10/15
to sona...@googlegroups.com
I am also facing the same problem that for all 20 messages captured in fxcop-report.xml 
either Skipping the FxCop issue at line 7 which has no associated file.
or Skipping the FxCop issue at line 35 whose file "c:\xyz.cs" is not in SonarQube.

Because of this the Rules Compliance is always showing 100%

Before starting the FxCop it is logged as 
05:59:44.319 INFO  - Sensor org.sonar.plugins.csharp.CSharpSensor@1e06006f done: 2750 ms
05:59:44.319 INFO  - Sensor org.sonar.plugins.csharp.CSharpFxCopProvider$CSharpFxCopSensor@49e01f04...
05:59:23.314 DEBUG - Updating semaphore batch-CApp2
05:59:27.346 INFO  - Analysis Complete.
05:59:27.439 INFO  - Writing 1 messages...
05:59:27.439 INFO  - Writing report to C:\.sonar\CApp2_ts.web\fxcop-report.xml...
05:59:27.439 INFO  - Done:00:00:09.4749676
05:59:27.471 INFO  - FxCopCmd.exe ended with the exit code: 1024
After completing the FxCop report generation
05:59:27.486 INFO  - Sensor org.sonar.plugins.csharp.CSharpFxCopProvider$CSharpFxCopSensor@42839fb7 done: 9725 ms
05:59:27.486 INFO  - Sensor InitialOpenIssuesSensor...
05:59:27.502 INFO  - Sensor InitialOpenIssuesSensor done: 16 ms
05:59:27.502 INFO  - Sensor ProjectLinksSensor...
05:59:27.518 INFO  - Sensor ProjectLinksSensor done: 16 ms
05:59:27.533 INFO  - Sensor VersionEventsSensor...
05:59:27.580 INFO  - Sensor VersionEventsSensor done: 47 ms
05:59:27.580 INFO  - Sensor FileHashSensor...
05:59:27.596 INFO  - Sensor FileHashSensor done: 16 ms
05:59:27.596 INFO  - Sensor SCM Sensor (wrapped)...
05:59:27.596 INFO  - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
05:59:27.596 INFO  - Sensor SCM Sensor (wrapped) done: 0 ms
05:59:27.596 INFO  - Sensor CPD Sensor (wrapped)...
05:59:27.596 INFO  - DefaultCpdEngine is used for cs
05:59:27.596 INFO  - Cross-project analysis disabled

For all the Populating index equally duplications also found. Does this cause some problem?
05:59:27.627 DEBUG - Populating index from [moduleKey=CApp2:ts.web, relative=ActionResults/StandardJsonResult.cs, abs=C:/StandardJsonResult.cs]
05:59:28.068 DEBUG - Detection of duplications for [moduleKey=CApp2:ts.web, relative=ActionResults/StandardJsonResult.cs, abs=C:/StandardJsonResult.cs]

Dinesh Bolkensteyn

unread,
Jul 14, 2015, 4:22:19 AM7/14/15
to sona...@googlegroups.com, gupta.s...@gmail.com
Hello,

You need to make sure that no files are excluded (such as *.g.cs ones) - this means that you should be able to find the "xyz.g.cs" file in SonarQube.
Check your SonarQube inclusions / exclusions, by default it might exclude *.g.cs files.

Then, *.xaml files are typically not imported in SonarQube, so all FxCop issues reported on those will be ignored.

Finally, the absolute paths to the sources in the FxCop report file must match the ones analyzed in SonarQube.
This means that you must perform the build of your project from the exact same location you launch the analysis.
Absolute paths to source files get hardcoded in the *.pdb files generated along with your assemblies, and those are used by FxCop to create its report.

imsenthi...@gmail.com

unread,
Jul 14, 2015, 8:27:00 AM7/14/15
to sona...@googlegroups.com, gupta.s...@gmail.com
Thanks Dinesh for your response!

I confirmed that there is no exclusion set in the Sonar Qube. Also, as you have mentioned i am starting the analysis from the same path where the projects are built.
Actually, the files and its contents i can able to view when i go via "Lines of Code" section. But, Rules Compliance section always shows 100%.

Details:
SonarQube: v5.0.1 running on linux
SonarRunner: v2.4 running from windows
DataBase: MySQL

Will there be windows - linux communication problem?

imsenthi...@gmail.com

unread,
Jul 16, 2015, 7:59:29 AM7/16/15
to sona...@googlegroups.com, imsenthi...@gmail.com, gupta.s...@gmail.com
We could resolve the below problem of "file is not in SonarQube" and the primary cause was for an unknown reason the C# 4.0 plugin doesn't go with SonarQube 5.0.1. So, replacing the 4.0 with 3.3 version the violations are reflected in dashboard.

Another thing that i noticed was the same problem occurs if the code is fetched and built by one user id (admin privilege) and starting the scan from same path where it was built but using different user id (no admin privilege).
Reply all
Reply to author
Forward
0 new messages