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 - [Introduce method] Unnecessary return statement
Summary: [Introduce method] Unnecessary return statement
Status: RESOLVED WONTFIX
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Linux
: P4 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-03 10:23 UTC by ssazonov
Modified: 2016-07-07 07:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Before / After (58.62 KB, image/png)
2014-02-03 10:23 UTC, ssazonov
Details

Note You need to log in before you can comment on or make changes to this bug.
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