From e5b3e078f362c813d2d9597194ea021efcce375f Mon Sep 17 00:00:00 2001 From: Amelie Renard Date: Mon, 25 Sep 2023 13:55:16 +0200 Subject: [PATCH] Modify rule S1155: Update title and add diff view --- rules/S1155/cfamily/metadata.json | 2 +- rules/S1155/cfamily/rule.adoc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rules/S1155/cfamily/metadata.json b/rules/S1155/cfamily/metadata.json index 3affd1819fd..05c8ea280cc 100644 --- a/rules/S1155/cfamily/metadata.json +++ b/rules/S1155/cfamily/metadata.json @@ -1,5 +1,5 @@ { - "title": "Do not check emptiness with a size method when a dedicated function exists", + "title": "\"empty()\" or \"is_empty()\" should be used to test for emptiness", "tags": [ "cppcoreguidelines", "clumsy" diff --git a/rules/S1155/cfamily/rule.adoc b/rules/S1155/cfamily/rule.adoc index fa87f753aa0..8aeefb0bd9e 100644 --- a/rules/S1155/cfamily/rule.adoc +++ b/rules/S1155/cfamily/rule.adoc @@ -4,7 +4,7 @@ Using a ``++size()++``, ``++length()++`` or ``++count()++`` method to test for e === Noncompliant code example -[source,cpp] +[source,cpp,diff-id=1,diff-type=noncompliant] ---- void fun(const std::vector &myVector) { if (myVector.size() == 0) { // Noncompliant @@ -15,7 +15,7 @@ void fun(const std::vector &myVector) { === Compliant solution -[source,cpp] +[source,cpp,diff-id=1,diff-type=compliant] ---- void fun(const std::vector &myVector) { if (myVector.empty()) { @@ -26,7 +26,7 @@ void fun(const std::vector &myVector) { == Resources -* https://github.com/isocpp/CppCoreGuidelines/blob/c553535fb8dda2839d13ab5f807ffbc66b63d67b/CppCoreGuidelines.md#enforcement-324[{cpp} Core Guidelines - T.143] - Don't write unintentionally nongeneric code +* {cpp} Core Guidelines - https://github.com/isocpp/CppCoreGuidelines/blob/036324/CppCoreGuidelines.md#reason-382[T.143 - Don't write unintentionally nongeneric code] ifdef::env-github,rspecator-view[]