Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to disable CxxSquidSensor #2228

Closed
AndreyAlifanov opened this issue Aug 13, 2021 · 4 comments · Fixed by #2080
Closed

Ability to disable CxxSquidSensor #2228

AndreyAlifanov opened this issue Aug 13, 2021 · 4 comments · Fixed by #2080
Assignees
Milestone

Comments

@AndreyAlifanov
Copy link

Hello.

I have a very big code base. When I import logs of PVS-Studio using this plugin, I should wait several hours.
Because of preprocessor work. I don't need this, so it would be nice to disable some of sensors.

For example, disabling of CxxSquidSensor increases speed of import approximately 5-6 times.

@guwirth
Copy link
Collaborator

guwirth commented Aug 13, 2021

Hello @AndreyAlifanov,

thank you for your feedback.

Unfortunately it is not that simple. SonarQube needs to read a file first (indexing) before issues can be assigned. Theoretically you could just read in a plain text file, but then all the software metrics (e.g. LoC, ...) are missing. The most expensive part is surely the preprocessor, if you leave it out you will not get a valid C++ syntax.
https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Scan-Source-Code

The easiest thing you can try is to reduce the number of include paths passed to the plugin.
https://github.com/SonarOpenCommunity/sonar-cxx/wiki/sonar.cxx.includeDirectories
https://github.com/SonarOpenCommunity/sonar-cxx/wiki/Detect-and-fix-parsing-errors

The plugin itself could optimize the preprocessor: Better support for include guards, precompiled header, parallel reading, ... etc.

Or we could try to determine the software metrics with simpler algorithms...
https://community.sonarsource.com/t/generic-language-sensor/41185

We are always open for good ideas (and support)!

Regards,

@AndreyAlifanov
Copy link
Author

Hello, @guwirth

thank you for quick answer.

I don't need correct C++ syntax at all in this particular case. :)
I only need to load PVS-Studio bugs and CodeCoverage logs.

For clarity. Our code base is about 8 millions lines of code. Solution is about 200 projects in C++.
Yes, we can divide it. But we want to get vision of complete solution, not parts.

PS
I tried to use includeDirectories - it's a terrific pain. As I include paths to Windows SDK includes - I get performance decreasing in about 10-20 times.

As I understand, SonarQube doesn't support generic-language-sensor now.

@guwirth
Copy link
Collaborator

guwirth commented Aug 13, 2021

Hi @AndreyAlifanov

I don't need correct C++ syntax at all in this particular case. :)

To calculate the technical debt you need software metrics.
To get valid software metrics you have to parse the code.
To parse the code you need the preprocessor.

  • else you visualize only the issues
  • you can't do syntax hightligthing

I tried to use includeDirectories - it's a terrific pain

Try to avoid includeDirectories: https://github.com/SonarOpenCommunity/sonar-cxx/wiki/sonar.cxx.includeDirectories

  • Hint: Since the cxx plugin only reads macros from the include files in order to parse the code syntactically in a correct way, it is often better to provide the missing macros instead of reading in all include files. Reading many include files (e.g. STL, Boost, MFC, ATL, ...) often slows down the analysis considerably. The recommendation is to include only include files for your own code.

As I understand, SonarQube doesn't support generic-language-sensor now.

Think SQ has no interest to provide such a plugin because they like to earn money with their own plugins. They have no interest in supporting external tools.

Regards,

@guwirth guwirth changed the title Ability to disable some sensors Ability to disable CxxSquidSensor Aug 14, 2021
andreydanin added a commit to andreydanin/sonar-cxx that referenced this issue Oct 5, 2021
Fix for SonarOpenCommunity#2228

SquidSensor can take significant amount of time on big projects.
Skip execution if all appropriate rules are disabled.
andreydanin added a commit to andreydanin/sonar-cxx that referenced this issue Oct 7, 2021
Fix for SonarOpenCommunity#2228

SquidSensor can take significant amount of time on big projects.
Skip execution if sonar.cxx.squidDisabled parameter is set to true.
andreydanin added a commit to andreydanin/sonar-cxx that referenced this issue Oct 7, 2021
Fix for SonarOpenCommunity#2228

SquidSensor can take significant amount of time on big projects.
Skip execution if sonar.cxx.squid.disabled parameter is set to true.
@guwirth guwirth added this to the 2.0.6 milestone Oct 11, 2021
@guwirth guwirth linked a pull request Oct 11, 2021 that will close this issue
@guwirth
Copy link
Collaborator

guwirth commented Oct 12, 2021

closed with #2080

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants