You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "maffe (via GitHub)" <gi...@apache.org> on 2024/09/17 16:32:00 UTC
Re: [I] Warning about unused variable disappears when adding private nested record [netbeans]
maffe commented on issue #4709:
URL: https://github.com/apache/netbeans/issues/4709#issuecomment-2356402010
> I've found another case, similar to the previous one, in which the visibility of a class member affects the result of this type of check. However, this time it affects a method parameter instead of a local variable. Look at this:
>
> ```java
> public class Main {
>
> public Main() {
> checkParameter(1);
> }
>
> public static void checkParameter(int myParameter) {
> // ^^^ This variable should be marked as unused,
> // but it isn't.
> }
>
> }
> ```
>
> Now, if you change the visibility of the method from `public` to `private`, NetBeans correctly detects that `myParameter` is not used at all in the body of the method.
I think it is intentional to not mark unused parameters in public methods since removing them would change your public API, breaking code using that method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists