Rule cpp:S3659 "Alternative operators should not be used" should not apply to the boolean operators

Hello @cyril.og,

Sorry for the late reply – holidays season.

To start with I agree with you that this rule is subjective.

  • “SonarWay” is what makes sense for most codebases and based on our data from the many C++ projects that we analyze we can conclude that using not, and, or is not common in the C++ community. && || ! is the common practice. So this rule is here to enforce this common practice.

  • Now in your case, using not, and, or might make more sense and that is fine. it is just not a common practice in the C++ community and that why we don’t recommend using them. For the python argument, it is very subjective. You can make the opposite argument for other languages. For example, they are not part of the C standard(they were added as part of the standard library, not the language since C90).
    In the end, if you think your codebase is special and you see value in using these alternatives you can always disable the rule.

  • For the severity I totally agree with you, there is no reason for it to be high. I will update it.

Thanks,

1 Like