Skip to content

Commit

Permalink
Modify rule S1155: Update title and add diff view
Browse files Browse the repository at this point in the history
  • Loading branch information
amelie-renard-sonarsource committed Sep 28, 2023
1 parent 603a496 commit e5b3e07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion rules/S1155/cfamily/metadata.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 3 additions & 3 deletions rules/S1155/cfamily/rule.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> &myVector) {
if (myVector.size() == 0) { // Noncompliant
Expand All @@ -15,7 +15,7 @@ void fun(const std::vector<int> &myVector) {

=== Compliant solution

[source,cpp]
[source,cpp,diff-id=1,diff-type=compliant]
----
void fun(const std::vector<int> &myVector) {
if (myVector.empty()) {
Expand All @@ -26,7 +26,7 @@ void fun(const std::vector<int> &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[]

Expand Down

0 comments on commit e5b3e07

Please sign in to comment.