Rule Set: ConfusingTernary
Description:
ConfusingTernary should treat negative comparisons with null as a positive condtion.
The condition "!= null" is often used to mean "the item is present" rather than "the item is not absent".
Rewriting using "== null" would make the code much harder to follow.
Code Sample demonstrating the issue:
if (parser.getArgumentById(VERSION_OPT) != null) {
...
} else if (parser.getArgumentById(HELP_OPT) != null) {
...
} else if (parser.getArgumentById(OPTIONS_OPT) != null) {
...
} else if (parser.getArgumentById(SERVER_OPT) != null) {
...
Running PMD through: Ant
sabberworm, oowekyala, JoyChopra1298, Cliabhach and getaceres
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4