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 241312

Summary: [Introduce method] Unnecessary return statement
Product: java Reporter: ssazonov
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED WONTFIX    
Severity: normal    
Priority: P4    
Version: 8.0   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: Before / After

Description ssazonov 2014-02-03 10:23:42 UTC
Created attachment 144715 [details]
Before / After

1. Create java class

package test;

public class Test {

    public void loop(int a) {
        String s = "";
        while (--a > 0) {
            //6
            if (a % 3 != 0) {
                s = s + "--, ";
                continue;
            }
            //7
            System.out.println(s + a + ", ");
            return;
            //8
        }
        if (s.endsWith(", ")) {
            s = s.substring(0, s.length() - 2);
        }
        System.out.println(s);
        return;
    }
}

2. Mark code between //7 and //8

3. From main menu: Refactor -> Introduce Method

4. Type any appropriate name and press Refactor

>> It generates method with unnecessary return statement (see attached image)

Product Version: NetBeans IDE Dev (Build 201402030001)
Java: 1.8.0; Java HotSpot(TM) 64-Bit Server VM 25.0-b67
Runtime: Java(TM) SE Runtime Environment 1.8.0-b126
System: Linux version 3.8.0-19-generic running on amd64; UTF-8; en_US (nb)
Comment 1 Martin Balin 2016-07-07 07:16:30 UTC
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue.

Thanks for your cooperation,
NetBeans IDE 8.2 Release Boss