I am working with the SonarQube Community Build v24.12.0.100206 and utilizing the custom plugin example provided by SonarQube (GitHub - sonar-custom-plugin-example, 10.x branch).
I am attempting to extend an existing language, specifically Java, by creating custom quality profiles with specific rules.
The goal is to ensure that multiple quality profiles can coexist without affecting the project measure tab.
What’s your specific coding challenge in developing your plugin?
When I create another quality profile for the same language (Java) and set it for a project, the measure tab stops displaying the bubble graph in the project overview.
I need guidance on whether this is an expected behavior or if there are specific steps required to maintain the graph display when switching quality profiles.
If relevant, please share the code that’s giving you problems:
Since the issue relates to the interaction between quality profiles and the measure tab, it is unclear whether the problem lies in the plugin code itself or in the SonarQube UI behavior.
If required, I can share relevant sections of the plugin code that define the rules and profile settings
You don’t need a plugin to create Quality Profiles. That can be done through the UI. You only need a plugin if you want to add new rules.
This is basic functionality. You can have as many profiles as you like.
Let’s look at what the bubble graph shows.
Bubble size is LoC and Coverage is the y-axis. I assume those things are approximately unvarying, regardless of which profile you’re applying.
Technical Debt is the x-axis. Technical Debt, as such, is only calculated for Maintainability / Code Smell issues.
Color is the “Worse of Reliability Rating and Security Rating”.
My hypothesis: your profiles contain only one type of Rule and thus one type of issue, so for each file that should appear as a bubble on the graph, a crucial value is missing because you aren’t applying any rules related to it.
Thanks for the detailed explanation and your helpful insights!
To clarify, I’ve developed a custom plugin that includes rules for multiple languages, and I’ve created separate quality profiles for each language using those rules. Everything works as expected up to SonarQube version 10.7 — the profiles apply correctly, and the Measures tab (including the bubble graph) displays data properly.
However, starting with the Community Build after version 10.7, the bubble graph in the project overview disappears when I apply a quality profile that uses rules from my plugin. The same plugin works fine from SonarQube 8.9 through 10.7, so this behavior seems to be introduced in versions beyond that.
Could this be related to changes in how SonarQube handles rule types, issue indexing, or metrics calculation in the latest versions? I would really appreciate any guidance on what might be causing this or how I can debug it further.
We create a project and run the initial scan using the Sonar command. This gives us the results and the measures graph displays correctly.
Then, we select a specific quality profile and re-run the scan. The results update according to the selected rules, and the bubble graph continues to work properly—all the way up to version 10.7.
To answer your other questions:
We haven’t seen any issues with the graph when using built-in profiles.
And you’re currently, actively running 10.8? Because it’s EOL in all editions. I thought you were just noting where the problem started.
Only the latest version of SonarQube Community Build is considered active, so you’ll need to upgrade and see if the situation is still replicable before we can help you.
This issue is a bit urgent for me as it is currently blocking my work. Would you please be able to take a look at the provided information and let me know if you require any further details?
I am trying to reproduce your issue, in the meantime could you share the response of api/measures/component_tree endpoint before and after setting your custom quality profile? I would like to see if there is a difference in responses. You may hide your component keys/names if you want or send it to me directly.
One more thing I have observed when I use this two rules I am able to see measures graph
profile.activateRule(“java”, “S2093”);
profile.activateRule(“java”, “S1075”);
and when I use this two
profile.activateRule(“java”, “S2204”);
profile.activateRule(“java”, “S6829”);
Measure graph disappears.
This is happening in sample plugin given by sonar community
Hi @amol_mane, thanks for the information provided!
I have investigated your findings and can confirm the problem. It appears there’s a change in how the code_smells measure is handled when no code smells are found during analysis.
Specifically:
In SonarQube 10.7, even when no code smells were detected, the code_smells measure with a value of 0 was still present in the history and included in the API response.
In versions after 10.7, if no code smells are found, the code_smells measure is absent from the API response.
This absence of the code_smells measure when its value is zero is causing the bubble chart in the Project Overview to not be displayed.
So, this doesn’t seems to be related to plugin, but a problem on SonarQube side. I’ve created a ticket to fix it on our side.
By the way, I suspect that with rules ‘S2093’ and ‘S1075’ enabled, your project might have found code smells, while with ‘S2204’ and ‘S6829’ no code smells were detected. Let me know if that’s not the case.
Unfortunately, I don’t have a workaround for you at the moment, but to wait for the fix to be implemented.
Thank you, @Stan, for confirming. We will wait for the issue to be resolved. Additionally, I have one more result JSON that I will attach. Please review and let me know what might be missing.