Conversation
|
@chrchr-github I remove these warnings for return values unless an explanation can be written. I don't personally know why we warn about the return. A warning about a my guess is that somebody didn't understand the purpose of knownconditiontruefalse and thought it would apply to return values and then I somehow didn't question it in the initial reviews and after that it grew.. |
|
In general I don't see it as a problem that a calculation has a known result. I think it makes sense to write calculations in clear text instead of writing magic numbers. That makes the code more explicit. |
| " return (c <= 'a' && c >= 'z');\n" | ||
| "}\n"); // TODO: use s? | ||
| ASSERT_EQUALS("[test.cpp:2:13] -> [test.cpp:2:25]: (style) Return value 'c>='z'' is always false [knownConditionTrueFalse]\n", errout_str()); | ||
| ASSERT_EQUALS("[test.cpp:2:13] -> [test.cpp:2:25]: (style) Condition 'c>='z'' is always false [knownConditionTrueFalse]\n", errout_str()); |
There was a problem hiding this comment.
instead of knownConditionTrueFalse.. this test case reminds me more about the "mutually exclusive comparisons" checker
|
If you are able to explain the warnings I would be interested in that. |
Here's an old ticket about inconsistent warnings for known function results: https://trac.cppcheck.net/ticket/10452 |
thanks as I read it the intention with that was not to warn about the return. But for conditions that contains such function call - and that is fine for me. |
No description provided.