This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 247418 - Redundant if hint needs better explanation -- mergable, not omittable
Summary: Redundant if hint needs better explanation -- mergable, not omittable
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0.1
Hardware: PC Windows XP
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-23 18:19 UTC by nimarukan
Modified: 2015-10-02 15:49 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nimarukan 2014-09-23 18:19:01 UTC
The redundant-if hint needs better explanation.
Maybe change 
"The if statement is redundant"
to
"The if statement is redundant or mergeable - merging it with another branch with the same body could produce a simpler condition expression."

Simply saying "The if statement is redundant" makes it sound like the if statement could be omitted because the cases it covers are also covered by other branches.  

However the below example shows that is not what it means.  The hint appears to mean that the if-condition could be combined or merged with another branch with the same if-body to produce a simpler test.  In the example below, the second 'if' gets the hint if its range meets or overlaps the first range, so the ranges could be combined into a single range.  It does not get the hint if there is a gap between the ranges, so combining them might take an '||'.  It does not get the hint if a statement is added to the if-body so the if-body is not the same as the earlier 'if'.


public class RendundantIf {
  static boolean hasX(int c) {
    //...
    if (0xA <= c && c <= 0xC) {
      return true;
    } else if (0xD <= c && c <= 0xF) { //hint says "The if statement is redundant"
      return true;
    } else {
      return false;
    }
  }
}
Comment 1 Svata Dedic 2015-10-02 15:49:17 UTC
Agree that a better wording could be used, but the suggested message is too long to read / understand from the tooltip popup.