If your question is about SonarQube for IDE in the IntelliJ Platform, VS Code, Visual Studio, or Eclipse, please post it in that sub-category.
Otherwise, please provide:
Operating system: Windows 11
IDE name and flavor/env: PyCharm Pro
And a thorough description of the problem / question:
The issue I’m having is that files in the tests directory are not being analyzed by the sonar IDE plugin. The files are detected when I submit my PR to GitHub though, as can be seen by the screenshot here.
I have tried manually running sonar for the individual files as well as for the entire project, but it does not find any detections in these files inside my IDE. My directory is marked as “test sources root” by PyCharm, though unmarking that did not change the behavior at all.
“Normal” rules aren’t generally run on test files, so it sounds like SonarQube for IDE is correctly recognizing your test files as test files. It sounds like the error here is that normal analysis is not.
If you’d like to pursue this nonetheless, can you share a verbose log from IDE startup, through to where you (don’t ) see this?
I feel obligated to point out that if test files are analyzed as normal lines of code, then they’re charged as normal lines of code against your license.
And if that’s what you want to do, then there should be a way to configure this in SonarQube for IntelliJ. But can we have those logs?
Can you clarify if you are in Connected Mode or not? The Gist you shared seems to be expired so I have not been able to access the logs
SonarQube for IDE relies on IDE (PyCharm) settings to determine whether the file is a test file or not. As mentioned in the docs
In the case where the IntelliJ IDE detects the test file for SonarQube for IntelliJ:
The file is under a test sources root. Those roots can be manually created by users or automatically populated by the IDE by relying on the build system such as Maven or Gradle, for example.
I understand your desire to analyze test files the same way as the server does, and I will flag this for our product team as a feature request.
Yes I believe so. For each project it asks me to link it to the project from sonarcloud and I do.
I can understand that some users may not want this enabled by default, especially if it incurs an extra cost. For me, I would like it because it brings the ability to automatically fix some of this issues via the context menu.
I appreciate adding this as a feature request. Thank you!