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 - False positive for the hint "Unused Assignment" in the variables year and month
Summary: False positive for the hint "Unused Assignment" in the variables year and month
Status: RESOLVED DUPLICATE of bug 238067
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: Macintosh Mac OS X
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-01-30 20:00 UTC by hildeberto
Modified: 2014-02-05 08:01 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
IDE log (269.51 KB, text/plain)
2014-01-30 20:00 UTC, hildeberto
Details
<no description> (160.77 KB, image/png)
2014-01-30 20:03 UTC, hildeberto
Details

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