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 222350 - Unable to detect two constant string (or other object) comparision
Summary: Unable to detect two constant string (or other object) comparision
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 7.3
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-18 21:18 UTC by ecerichter
Modified: 2013-09-02 14:19 UTC (History)
1 user (show)

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 ecerichter 2012-11-18 21:18:32 UTC
Product Version = NetBeans IDE Dev (Build 201211150001)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_09
Runtime = Java HotSpot(TM) 64-Bit Server VM 23.5-b02

NetBeans must be able to notify user that he is doing comparision between two constants that will never be true.
For instance, consider the following code:

/** Example with String **/
String acao = request.getParameter("action");

if("doSave".equals("acao")) { // this line should be marked - will never be true.
  // do somethig when true - that means, never!
}


/** Example with Integer **/
Integer i = Integer.valueOf(5);

if(i.equals(new Integer(8))) { // this line should be marked - will never be true.
  // do somethig when true - that means, never!
}


/** Example with BigDecimal **/
BigDecimal d1 = new BigDecimal("10.0");
BigDecimal d2 = new BigDecimal("20.0");

if(d1.compareTo(d2)==0) { // this line should be marked - will never be true.
  // do somethig when true - that means, never!
}
/** end of examples **/



Even if only the first case (string comparision) is covered, then it will be great.

Regards,

Edson