[java] New rule IdenticalConditionalBranches#6083
Conversation
|
Compared to main: (comment created at 2025-10-24 10:46:18+00:00 for ffa480c) |
There was a problem hiding this comment.
Good idea, thank you
I wonder if another name would be more appropriate. Maybe "IdenticalIfStatementBranches". For one I'm not a fan of the word "useless" as it feels a bit rough, but that's secondary. The main reason is that "UselessCondition" sounds a bit vague and could be confused with a rule that checks conditions that are always true/false for instance. Also if-statements are not the only ones that have conditions (see loops), but they're the only ones checked by this rule.
...va/src/test/resources/net/sourceforge/pmd/lang/java/rule/errorprone/xml/UselessCondition.xml
Outdated
Show resolved
Hide resolved
caecdc2 to
6ef2900
Compare
adangel
left a comment
There was a problem hiding this comment.
Thanks!
I'll update the release notes and merge it for 7.18.0.
...ain/java/net/sourceforge/pmd/lang/java/rule/errorprone/IdenticalConditionalBranchesRule.java
Outdated
Show resolved
Hide resolved
8c6454c to
1c95557
Compare
Describe the PR
Add a rule for finding useless
ifs and ternary expressions.Proposed Rule Name: IdenticalConditionalBranches
Proposed Category: Error Prone
Description:
Conditional statement that does the same thing when the condition is true and false
is either incorrect (one of the branches should be changed) or redundant
(can be replaced by one of its branches).
Code Sample:
Possible Properties: none
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by github actions)