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 252305 - Cannot avoid warning about a confusing indentation
Summary: Cannot avoid warning about a confusing indentation
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.1
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-08 16:05 UTC by cezariusz
Modified: 2015-09-25 01:47 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cezariusz 2015-05-08 16:05:40 UTC
Product Version: NetBeans IDE Dev (Build 201505020001)
Java: 1.8.0_45; Java HotSpot(TM) 64-Bit Server VM 25.45-b02
Runtime: Java(TM) SE Runtime Environment 1.8.0_45-b14
System: Windows 7 version 6.1 running on amd64; UTF-8; pl_PL (nb)

The following code leads to the "Confusing indentation" warning. I applied code format using the default formatting style.

Testcase:

    public void demo(int check, boolean a, boolean b) {
        switch (check) {
            case 1:
                if (a) {
                    if (b) {
                        System.out.println("a AND b");
                    } else {
                        System.out.println("a AND NOT b");
                    }
                } else // a is false
                if (b) {
                    System.out.println("NOT a AND b");
                } else {
                    System.out.println("NOT a AND NOT b");
                }
                break; // <-- warning
            case 2:
                System.out.println("Don't case");
                break;
            default:
                throw new IllegalArgumentException(check + " is not allowed");
        }
    }

Note the warning disappears after removing the "a is false" comment and reformatting code. The strange formatting and comment location comes from bug 252303.
Comment 1 Jiri Prox 2015-05-11 08:27:45 UTC
reproducible
Comment 2 Svata Dedic 2015-09-22 12:34:53 UTC
Wrong formatting; the if-elseif is AFAIK not a special case, the if inside else should be indented
Comment 3 Dusan Balek 2015-09-24 12:55:12 UTC
Fixed in jet-main.

http://hg.netbeans.org/jet-main/rev/4632127cda3e
Comment 4 Quality Engineering 2015-09-25 01:47:42 UTC
Integrated into 'main-silver', will be available in build *201509250002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/4632127cda3e
User: Dusan Balek <dbalek@netbeans.org>
Log: Issue #252305 - Cannot avoid warning about a confusing indentation - fixed.