Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 341817

Summary: "Parameter is never read" warning for private methods only
Product: [Eclipse Project] JDT Reporter: Ryan F <rflegel>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P5 CC: amj87.iitr, greg.hutchinson, markus.kell.r, remy.suen
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Ryan F CLA 2011-04-04 12:08:25 EDT
Build Identifier: M20100909-0800

Currently, the "Parameter is never read" warning will trigger on all methods if it is enabled.

It would be nice if this warning could be set to only trigger on private methods or private & protected (it would be nice if both options were available).

Having the warning trigger on public methods is an issue, because we often want to keep the API intact, which means unnecessary warnings that we have to suppress.

Reproducible: Always
Comment 1 Remy Suen CLA 2011-04-04 12:15:26 EDT
(In reply to comment #0)
> Having the warning trigger on public methods is an issue, because we often want
> to keep the API intact, which means unnecessary warnings that we have to
> suppress.

You can tell the compiler to ignore parameters that are documented with the '@param' javadoc tag.
Comment 2 Ryan F CLA 2011-04-04 12:45:13 EDT
Hi Remy,

Thanks, I'm aware of that feature, but that would create a bunch of unnecessary documentation for us. It would be the same as having to suppress each warning.

-- 
Ryan
Comment 3 Markus Keller CLA 2011-04-04 13:10:47 EDT
If it's an API that should stay stable, then it wouldn't hurt to document it. 

Having a special option just for private methods sound a bit arbitrary. Why not another one for package private methods and yet another one for protected methods? I wouldn't add this.
Comment 4 Ryan F CLA 2011-04-04 13:21:57 EDT
You're right, too much customization might be a bit cumbersome. I see it being useful in the same way that "Unused local or private member" is useful.

At the very least, I think the option should be there to ignore warnings for non-private members.
Comment 5 Ayushman Jain CLA 2011-04-05 05:51:13 EDT
I don't see a convincing reason to add the warning. It won't take much time to document the param in the API itself. Someone else can have such an argument for some other warning also to be suppressed for public methods. I think this customization should not be added.
Comment 6 Greg Hutchinson CLA 2011-04-05 10:55:07 EDT
However - an unused parameter in a private method is always an error, where all the other visibility modifiers can produce false positives. Of course you wouldn't want to make a different warning for every visibility modifier, but in this case, I can see this as being really useful.