The result of a string's find is used as a condition, which is true when the text is missing and false when it is at the start
What it finds
find returns a position, and std::string::npos when nothing is found; as a condition, npos is true and a match at position 0 is false, the opposite of what if (s.find(x)) reads as. The result is compared with std::string::npos, or contains is used.
From the rule's source, string_find_as_condition.rs.
Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/cpp:string-find-as-condition" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/cpp:string-find-as-condition] reason="..."tx0 explain tx0/cpp:string-find-as-condition shows the same in the terminal. Found a false positive? Report it.