51 lines
1.6 KiB
Plaintext
51 lines
1.6 KiB
Plaintext
== Why is this an issue?
|
|
|
|
The use of a string literal in a boolean test is likely an error since the test will always evaluate to true (i.e. the string is a non-0 value).
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,text]
|
|
----
|
|
if ("foo") { // Noncompliant - always evaluates to true
|
|
...
|
|
} else {
|
|
// unreachable, never executed
|
|
}
|
|
----
|
|
|
|
|
|
== Resources
|
|
|
|
* CWE - https://cwe.mitre.org/data/definitions/571[CWE-571 - Expression is Always True]
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 2 Jul 2015, 13:54:38 Massimo PALADIN wrote:
|
|
\[~ann.campbell.2] could you please help me to complete this spec?
|
|
|
|
=== on 2 Jul 2015, 15:07:55 Ann Campbell wrote:
|
|
\[~massimo.paladin] I've updated the title and description (not sqale yet) but I think this is a special case of RSPEC-2583
|
|
|
|
=== on 2 Jul 2015, 15:33:21 Massimo PALADIN wrote:
|
|
\[~ann.campbell.2] I made a small change because ``++if++`` was too restrictive, we may have it in a while condition, etc...
|
|
|
|
=== on 2 Jul 2015, 15:38:17 Ann Campbell wrote:
|
|
Updated [~massimo.paladin], but what about the fact that this is a subset of RSPEC-2583?
|
|
|
|
=== on 2 Jul 2015, 16:10:37 Evgeny Mandrikov wrote:
|
|
\[~ann.campbell.2] [~massimo.paladin] what about the fact that RSPEC-1768 is also a subset of RSPEC-2583? :)
|
|
|
|
=== on 3 Jul 2015, 09:31:43 Massimo PALADIN wrote:
|
|
\[~ann.campbell.2] why only one reference and not all references from RSPEC-2583? we also detect case like ``++!"foo"++``.
|
|
|
|
=== on 6 Jul 2015, 14:52:15 Ann Campbell wrote:
|
|
Assigning to [~evgeny.mandrikov] pending outcome of discussion about merging into RSPEC-2583
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|