Is there a way to limit analysis to a specific list of c#/vb files?

(Seth Rider) #1

Hi,

We have a relatively large project that we’re using with sonarqube (800k lines of c#, 200k lines of vb).
Regular scans are relatively fine, but take roughly 1 hour with our whole build process (sonarqube adds nearly 45 minutes).

We would like to enable scans on pull requests, but without the entire overhead.

I tried passing a list of changed files to sonar.source (using a mixture of git + powershell fun), but it analyses all of the files anyway when using Integrate with MSBuild. It seems to get the list from msbuild and append my list of files to the bottom (checked the .properties file on the build server).

I also tried switching to the standalone scanner, and it just analyses the files that I send it.
However, it doesn’t find any issues, I believe because c#/vb files are meant to be done with Integrate with MSBuild.

Is there a way to either:
a) analyse c#/vb with the standalone scanner
b) limit the files analysed with msbuild?

Many thanks!

Must-share information (formatted with Markdown):

  • Versions:
  • SonarQube version: 7.7.0.23042
  • Azure Devops (cloud)
  • VSTS sonarqube plugin 4.0
  • Trying to acheive: Pull request decoration on 1m SLOC repository in a reasonable time
  • what have you tried so far to achieve this: passing a list of changed files, both with standalone scanner and with the msbuild integration
1 Like
(G Ann Campbell) #2

Hi,

To be clear, this is not territory we target, so I don’t have a facile answer for you. Nonetheless, I think you may be able to accomplish this by excluding everything and then re-including the files you want to analyze. This does imply some perhaps intense pre-analysis scripting to set up your inclusions.

 
Good luck,
Ann

(Seth Rider) #3

Thanks, Ann!

I’ll need to test it further, but it seems to be at least partially working :slight_smile:

For readers who are interested the general idea is git diff (targetbranch)…HEAD.

I’ll update here findings on how it performs on the 1m SLOC codebase (been testing on a much smaller repository).