diff --git a/rules/S6185/cfamily/metadata.json b/rules/S6185/cfamily/metadata.json index b1df3afeec..e8070ffad3 100644 --- a/rules/S6185/cfamily/metadata.json +++ b/rules/S6185/cfamily/metadata.json @@ -25,5 +25,5 @@ "defaultQualityProfiles": [ "Sonar way" ], - "quickfix": "unknown" + "quickfix": "targeted" } diff --git a/rules/S6185/cfamily/rule.adoc b/rules/S6185/cfamily/rule.adoc index e585ea0509..604d7747d2 100644 --- a/rules/S6185/cfamily/rule.adoc +++ b/rules/S6185/cfamily/rule.adoc @@ -1,7 +1,7 @@ ``++std::format++``, introduced by {cpp}20, enables straightforward string construction out of values of various types. -Before {cpp}20 one popular way to obtain the same result was the conversion of the values with ``++std::to_string++`` and piecewise string concatenation. +Before {cpp}20, one popular way to obtain the same result was the conversion of the values with ``++std::to_string++`` and piecewise string concatenation. ``++std::format++`` is strictly superior. It is more efficient because it constructs the string in-place instead of copying substrings one by one. It is also often shorter and easier to read because the format pattern is presented in a single piece and not scattered across the concatenation expression. @@ -15,7 +15,7 @@ This rule reports string concatenation cases that can be replaced by ``++std::fo [source,cpp] ---- std::string greeting(int n) { - return "Hello, player " + std::to_string(n) + "."; + return "Hello, player " + std::to_string(n) + "."; // Noncompliant } ---- @@ -25,7 +25,7 @@ std::string greeting(int n) { [source,cpp] ---- std::string greeting(int n) { - return std::format("Hello, player {}.", n); + return std::format("Hello, player {}.", n); // Compliant } ----