Skip to content

Only analyze files that are contained in the 'JSON Compilation Database'#2430

Merged
guwirth merged 1 commit intoSonarOpenCommunity:masterfrom
guwirth:jsondb-files
Nov 15, 2022
Merged

Only analyze files that are contained in the 'JSON Compilation Database'#2430
guwirth merged 1 commit intoSonarOpenCommunity:masterfrom
guwirth:jsondb-files

Conversation

@guwirth
Copy link
Copy Markdown
Collaborator

@guwirth guwirth commented Sep 30, 2022

In case of sonar.cxx.jsonCompilationDatabase is used, limit the analyzed files to the files contained in the 'JSON Compilation Database' file. The sensor is an intersection of the files configured via sonar.projectBaseDir and the files contained in the 'JSON Compilation Database' file.

In the past, all files configured via sonar.projectBaseDir were always analyzed and only the configuration (INCLUDES, MACROS) was read from the 'JSON Compilation Database'.

  • filter sonar.projectBaseDir files result
  • add a 'JSON Compilation Database' support integration test

Hint: Unfortunately, the sensor cannot control the indexing of the source files. Therefore, all files that belong to language CXX and are located within the directory sonar.projectBaseDir are loaded onto the server, but are no longer analyzed, which saves time.


This change is Reviewable

@guwirth guwirth added this to the 2.1.0 milestone Sep 30, 2022
@guwirth guwirth self-assigned this Sep 30, 2022
In case of 'sonar.cxx.jsonCompilationDatabase' is used, limit the analyzed files to the files contained in the 'JSON Compilation Database' file. The sensor is an intersection of the files configured via 'sonar.projectBaseDir' and the files contained in the 'JSON Compilation Database' file.

In the past, all files configured via 'sonar.projectBaseDir' were always analyzed and only the configuration (INCLUDES, MACROS) was read from the 'JSON Compilation Database'.

- filter 'sonar.sources' files
- add a JSON Compilation Database support integration test
@guwirth
Copy link
Copy Markdown
Collaborator Author

guwirth commented Oct 22, 2022

@thyros and @Kinokin there is another improvement for the Json Compilation Database sensor. Maybe you can try it and give feedback.

https://github.com/SonarOpenCommunity/sonar-cxx/suites/8897425714/artifacts/407082091

@guwirth guwirth merged commit 24420f4 into SonarOpenCommunity:master Nov 15, 2022
@Kinokin
Copy link
Copy Markdown

Kinokin commented Nov 16, 2022

Well, this may break our analysis. Just a few days ago we re-enabled sonar-cxx scanning after

  • using a unity build to get clang-tidy from 2h down to 10 minutes analysis time
  • using 'latest' plugin (2.1 (build 311))
    which worked well for us.

Unity build looks like

unity_lib.cpp:
include "source_a.cpp"
include "source_b.cpp"
include "source_c.cpp"
include "source_d.cpp"
and compilation database only contains unity_lib.cpp

Filtering by compilation database will drop all source_*.cpp files now.
Can this behaviour be disabled?

@guwirth
Copy link
Copy Markdown
Collaborator Author

guwirth commented Nov 16, 2022

Hi @Kinokin,

currently there is no option but we can add one.

# default False
sonar.cxx.jsonCompilationDatabase.analyzeOnlyContainedFiles=True/False

What do you think?

Regards

@Kinokin
Copy link
Copy Markdown

Kinokin commented Nov 17, 2022

Yes, this would be sufficient, thanks!

@guwirth
Copy link
Copy Markdown
Collaborator Author

guwirth commented Nov 18, 2022

Hi @Kinokin you can try with latest snapshot, see #2449

@guwirth guwirth deleted the jsondb-files branch February 8, 2023 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants