Hello C++ developers,
We’ve further stepped up our game in supporting MISRA C++ 2008! As promised in our blog post earlier this year, we’ve been working hard to better support the MISRA C++ 2008 standard. We’ve just released a new version of our C++ analysis engine and it includes 9 new rules supporting MISRA C++ 2008 bringing the total to 43 rules compliant with this standard.
- S1042: Handlers of a function-try-block implementation of a class constructor or destructor shall not reference non-static members from this class or its bases. (Bug)
- S1002: Multiple declarations for an identifier in the same namespace shall not straddle a using-declaration for that identifier. (Bug)
- S5359: Each operand of the ! operator, the logical && or the logical || operators shall have type bool. (Bug)
Code Smell Detection:
- S994: A variable which is not modified shall be const qualified. (Code Smell)
- S963: In the definition of a function-like macro, each instance of a parameter shall be enclosed in parentheses, unless it is used as the operand of # or ##. (Code Smell)
- S5356: An object with pointer type shall not be converted to an unrelated pointer type, either directly or indirectly. (Code Smell)
- S5357: An object with integral type or pointer to void type shall not be converted to an object with pointer type. (Code Smell)
- S5358: A cast should not convert a pointer type to an integral type. (Code Smell)
- S5350: Pointer and reference local variables should be “const” if the corresponding object is not modified. (Code Smell)
In parallel to this effort related to MISRA C++ 2008, we started to look at the C++ Core Guidelines. From this study, we extracted 3 rule ideas that are implemented in this release.
- S5421: Non-const global variables should not be used. (Code Smell)
- S5416: “using” should be preferred to “typedef” for type aliasing. (Code Smell)
- S5408: A “constexpr” function should not be declared “inline”. (Code Smell)
For more information you can read the changelog.
You can already enjoy these new features on SonarCloud. As for SonarQube, this will be built-in the next version (8.0), and meanwhile you can get it by installing v6.4 of the C/C++/Objective-C analysis engine.
All feedback is welcome.