rspec/rules/S3950/cfamily/rule.adoc
Fred Tingaud 16f6c0aecf
Inline adoc when include has no additional value (#1940)
Inline adoc files when they are included exactly once.

Also fix language tags because this inlining gives us better information
on what language the code is written in.
2023-05-25 14:18:12 +02:00

39 lines
729 B
Plaintext

== Why is this an issue?
Comparing two identical strings will always yield the same result and doesn't achieve anything. This is likely to be made in error.
This rule raises an issue when ``++strcmp++`` or ``++strncmp++`` is called with two identical literal strings or twice the same variable.
=== Noncompliant code example
[source,cpp]
----
if (strcmp("F00", "F00")) { // Noncompliant
doSomething();
}
if (strncmp(s1, s1, 10)) { // Noncompliant
doSomethingElse();
}
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Review this comparison, both strings are identical.
=== Highlighting
The full strcmp call
endif::env-github,rspecator-view[]