13 new rules to help you make the best of C++20's `std::format` feature

Happy new year dear C, C++ and Objective-C users.

To start with some great new C++ features for 2023, we are glad to bring you 13 new rules to make the best of C++20’s std::format feature.

  • Rule S6185: std::format should be used instead of string concatenation and std::to_string
  • Rule S6482: Explicit argument indexing in std::format should be used only for non-trivial ordering
  • Rule S6483: Width, alignment, and padding format options should be used consistently
  • Rule S6484: Concatenated std::format outputs should be replaced by a single invocation
  • Rule S6487,S6488: std::format should not be missing indexes
  • Rule S6489: Calls to std::format with a locale should use the "L" flag
  • Rule S6490: Arguments corresponding to width and precision formatting options should be integers
  • Rule S6491: std::format numeric types should be 0-padded using the numerical padding and not the character padding
  • Rule S6492: Use std::format rather than std::vformat when the format string is known at compile time
  • Rule S6493: The result of make_format_args should be passed directly as an argument
  • Rule S6494: C++ formatting functions should be used instead of C printf-like functions
  • Rule S6495: std::format should be used instead of standard output manipulators

These new rules will be available with SonarQube 9.9 LTS starting from Developer Edition. They will be available shortly on SonarCloud and soon on SonarLint.

As always, you can see what’s coming next and vote for C and C++ features you would like to see in SonarQube, SonarCloud, and SonarLint.

Cheers

2 Likes