Need float exclusion for rule cpp:S813

In our project we would like

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    • SonarQube 9.7.1-enterprise
  • what are you trying to achieve
    • Have a sensible ruleset for us based on MISRA rules.
  • what have you tried so far to achieve this
    • Parametrize and select appropriate rules.

The rule cpp:S813: “typedefs that indicate size and signedness should be used in place of the basic types”, currently applies to integer and floating point types. We would like to activate it only for integer types, because it doesn’t make much sense in our view to apply this to floating point types, since a) their bit-width is not usually the issue, and b) the layout and operations are much more important to ascertain in this case, so this creates a false sense of security.

For this reason we would like to have a parameter to disable this rule for float and double and only enable it for integer types.

Hi @Carl,

Since this rule follows MISRA guidelines, we try to stick to them as much as possible, and in this case, it means reporting on float.

But you’ll be happy to know that the upcoming version of MISRA agrees with you on this point, and should no longer mention floating point types in this rule. So stay tuned!

1 Like

Hi @JolyLoic ,

that’s good news, although I think it wouldn’t hurt to allow parametrization in the meantime. The parameter could still be default true for reporting on float, conforming to MISRA, but would allow projects that want to deviate here to do so systematically without disabling this otherwise very useful rule.

Hi @Carl,

We don’t add parameters to rules unless the rule makes no sense without them because it makes the product significantly more complex to use.

Hopefully, the release date of a version with the improved rule should not be too different from what the release date of a version with a parameter would have been.

HI @JolyLoic ,

I’m sad to hear that, if you ask me it adds no more complexity for the user if the defaults lead to the same behavior as before.

I also hope the release is soon of the new ruleset.