Improvement: Don't log "... does not exist in the analysis context" warnings for excluded files

Which versions are you using (SonarQube: 9.6.1 (build 59531)

What are you trying to achieve:

We have a project P and shared code. The shared code has its own SonarQube project, but it exists as a folder in project P. We don’t want to analyze the shared code when analyzing the project P that consumes it.
So, we excluded the shared code folder via /d:sonar.exclusions="**/SharedCode/**/*,

Problem:
There are logs of warnings logged that appear in our Jenkins build logs.

WARN: File ‘SharedCode\SomeFile1.cs’ referenced by the protobuf ‘MetricsInfo’ does not exist in the analysis context
WARN: File ‘SharedCode\SomeFile2.cs’ referenced by the protobuf ‘MetricsInfo’ does not exist in the analysis context
WARN: File ‘SharedCode\SomeFile3.cs’ referenced by the protobuf ‘MetricsInfo’ does not exist in the analysis context

There are almost 1.000 of these entries.

Is it possible to not log them?
We excluded the whole shared code directory. So, from our point of view, it doesn’t make sense to get 1.000 warnings about each of the files in it, especially because the warnings confuse other developers in our company.

What have you tried so far to achieve this

We researched and found other post about this issue (e.g. Static Analysis fails only for certain part - #4 by Jeff_Zapotoczny ), but we would rather get rid of the warnings instead of ignoring them (as suggested in that post).

1 Like

Hi Jam,

Thanks for your feedback. There is an ongoing effort to improve how file exclusions are handled by our analyzers. As this topic touches multiple products (SonarLint, Scanner, sonar-dotnet) I cannot provide yet an ETA.

You can follow the progress for sonar-dotnet here: https://github.com/SonarSource/sonar-dotnet/issues/6328