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 241195

Summary: False positive for the hint "Unused Assignment" in the variables year and month
Product: java Reporter: hildeberto
Component: HintsAssignee: Svata Dedic <sdedic>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: P3    
Version: 8.0   
Hardware: Macintosh   
OS: Mac OS X   
Issue Type: DEFECT Exception Reporter:
Attachments: IDE log
<no description>

Description hildeberto 2014-01-30 20:00:29 UTC
Product Version = NetBeans IDE 8.0 Beta (Build 201401141042)
Operating System = Mac OS X version 10.9.1 running on x86_64
Java; VM; Vendor = 1.7.0_40
Runtime = Java HotSpot(TM) 64-Bit Server VM 24.0-b56

        int year, month, currentYear = 0;
        for(UserAccount userAccount: userAccounts) {
            registrationDate = Calendar.getInstance();
            registrationDate.setTime(userAccount.getRegistrationDate());
            if(currentYear == 0) {
                currentYear = registrationDate.get(Calendar.YEAR);
            }

            year = registrationDate.get(Calendar.YEAR) - currentYear;
            month = registrationDate.get(Calendar.MONTH);
            data[year][month] += 1;

            if(userAccount.getDeactivationDate() != null) {
                deactivationDate = Calendar.getInstance();
                deactivationDate.setTime(userAccount.getDeactivationDate());

                year = deactivationDate.get(Calendar.YEAR) - currentYear;
                month = deactivationDate.get(Calendar.MONTH);
                data[year][month] -= 1;
            }
        }

This sample was extracted from the class https://github.com/htmfilho/yougi/blob/master/src/main/java/org/cejug/yougi/web/report/MembershipGrowth.java. When I opened the project on Netbeans and opened this class the hint "Unused Assignment" appeared in the lines 114, 116, 122 and 123. However, the variables year and month are used  in the data array, so their values are actually used.
Comment 1 hildeberto 2014-01-30 20:00:36 UTC
Created attachment 144607 [details]
IDE log
Comment 2 hildeberto 2014-01-30 20:03:07 UTC
Created attachment 144608 [details]
<no description>
Comment 3 Jiri Prox 2014-02-05 08:01:57 UTC

*** This bug has been marked as a duplicate of bug 238067 ***