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 247872

Summary: .isEmpty() should be suggested for .equalsIgnoreCase("")
Product: java Reporter: davidje13
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 8.0.1   
Hardware: PC   
OS: Windows 7   
Issue Type: ENHANCEMENT Exception Reporter:

Description davidje13 2014-10-11 13:42:31 UTC
Some legacy code I've been patching up contains lots of:

if( myString.equalsIgnoreCase("") ) { ... }

(I really have no idea what the original coder was thinking, but they did this *everywhere*). It seems that the .equals("") hint/rewriter could trivially be extended to catch these too.
Comment 1 Jiri Prox 2014-10-13 08:50:56 UTC
You can create your own hint for this.


Here is guide how to create and run your own hint with transformation:
http://services.netbeans.org/synergy/client/app/#/case/2637/suite/1175/v/1


Here is code of the hint:
$1.equalsIgnoreCase("") :: $1 instanceof java.lang.String
=> $1.equals("")
;;
Comment 2 Svata Dedic 2015-04-07 12:51:45 UTC
There's already a hint to convert equals("") to isEmpty or size() == 0 (for acient JREs) IMHO
Comment 3 Svata Dedic 2015-04-14 10:46:59 UTC
Implemented as jet-main#24c71c3cf09b
Comment 4 Quality Engineering 2015-04-23 02:11:20 UTC
Integrated into 'main-silver', will be available in build *201504230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/24c71c3cf09b
User: Svata Dedic <sdedic@netbeans.org>
Log: #247872: extended String.equals hint to cover equalsIgnoreCase