From c6acefb37f14661ed5dfe80fa85d143db09e975c Mon Sep 17 00:00:00 2001 From: abbas-sabra-sonarsource <49131500+abbas-sabra-sonarsource@users.noreply.github.com> Date: Tue, 6 Dec 2022 23:10:58 +0100 Subject: [PATCH] Modify rule S6185: improve description --- rules/S6185/cfamily/metadata.json | 2 +- rules/S6185/cfamily/rule.adoc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) 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 } ----