I am using SonarQube Cloud for C++ (analyszer v6.66).
When overriding a virtual function declared in an external library (Qt), I get some issues (S813, S994, S5008…) due to this API. I can’t fix them while respecting the API.
I think some rules (all ?) should be disabled on a function’s signature when the function is set as override.
Maybe there could be in SonarQube Cloud GUI also an option “Accept external constraint”.
We do have several rules that do not make much sense when applied to a function signature that you don’t really control. override is one such case, but not the only one (for instance, when you assign the function to a function pointer).
We identified several impacted rules, and this topic is high on our priority list. CPP-5365 is one of our tickets related to this topic.
However, I’m not entirely sure with S813: If you really want to enable this rule, you can apply it even when overriding, since you can use a typedef even if the overridden function does not (since typedefs as not strong in C++…).
Thanks for your answer. I hope CPP-5365 will be adressed soon, because its priority is not set as “high”, but as “normal”.
Regarding S813… You’re generally right, and I mentionned it only because it was in the list of raised issues. I should have removed it. BUT… When the concerned overriding function is used in a connection declaration in Qt, you can’t write int32_t instead of int :
Typedefs and namespaces cannot be resolved.
Yes, we could use the functor-based syntax, but we have so much legacy code…
Thank you so much for this information. I did not know it, and I’ve added S813 (with the extra details) to the list of impacted rules.
We are not using the priority field from Jira to prioritize our work, and I can assure you that this topic is high on the list.
That being said, most of our ressources are currently assigned to implementing MISRA C++:2023 rules, so I cannot promise any quick resolution of this ticket.
No, S1481 is about variables.
I can’t remember the specific issue related to Qt SIGNALS/SLOTS, but I am studying now false posivitives for “unused” functions (not related to Qt) which are actually used, and raise the issue S5536.