Thread: green analysis box : parameter not used


Permlink Replies: 6 - Pages: 1 - Last Post: Nov 14, 2006 12:54 PM Last Post By: Didier Laurent
Jan Vervecken (...

Posts: 1,636
Registered: 10/29/98
green analysis box : parameter not used
Posted: Oct 24, 2006 4:02 AM
Click to report abuse...   Click to reply to this thread Reply
hi

The Java code editor in JDeveloper shows an "analysis completed" square in the right margin.
Of course I try to get a green analysis box, but one kind of warning often prevents this.
If I don't use a method parameter, e.g. when implementing an interface, I get a warning about that.
The scenario below seems to add confusion to this (see the comments in the code):

- the MyBaseClass class:
public class MyBaseClass
{
	public void someMethod(String pSomeString)
	{
		// I don't use pSomeString.
		// waring shown : Parameter 'pSomeString' not used
	}
}

- the MySubClass class:
public class MySubClass extends MyBaseClass
{
	public void someMethod(String pSomeString)
	{
		// still don't use pSomeString, but analysis box is green
		// the box tooltip says : No errors or warnings found.
	}
}

(*) my question
Is it possible to configure JDeveloper to ignore the "parameter not used" warning? Or even to parameterize such configuration with "ignore only for interface method implementations" or similar options?

regards
Jan Vervecken
Didier Laurent

Posts: 611
Registered: 01/10/01
Re: green analysis box : parameter not used
Posted: Oct 24, 2006 4:44 AM   in response to: Jan Vervecken (... in response to: Jan Vervecken (...
Click to report abuse...   Click to reply to this thread Reply
Jan,

you can parameterize it through Tools -> Preferences.
Expand Audit -> Profiles
In the right panel, expand Usages
Unselect Unused Parameter, or change one of the values at the right.

F.ex., Severity=Assist and Style=Warning will display the Green Analysis Box, but still highlight the parameter.

Regards,

Didier.
Jan Vervecken (...

Posts: 1,636
Registered: 10/29/98
Re: green analysis box : parameter not used
Posted: Oct 24, 2006 5:19 AM   in response to: Didier Laurent in response to: Didier Laurent
Click to report abuse...   Click to reply to this thread Reply
Thanks for your reply Didier.

This is what I need. (I saved my profile, so I also had to select that Code Assist Profile on the Audit panel.)

This explanation is shown "Unused parameters add unnecessary complexity and overhead to clients and should be removed if possible. Removal may not be possible if the method implements a superclass or interface method which cannot be modified.".

Maybe it could be a (future) option to not warn about unused parameters if "removal is not possible"?

Do you also have an explanation for the "warning - no warning" behavior in the "MyBaseClass - MySubClass" example?

regards
Jan
Didier Laurent

Posts: 611
Registered: 01/10/01
Re: green analysis box : parameter not used
Posted: Oct 24, 2006 6:28 AM   in response to: Jan Vervecken (... in response to: Jan Vervecken (...
Click to report abuse...   Click to reply to this thread Reply
Jan,

sorry, I concentrated on your question, but missed the point that the behaviour was inconsistent between the class and the subclass.

I have currently no explanation.
I remember that in old releases of JDeveloper, we were always displaying the warning, even for Interfaces.We changed it - maybe too drastically (?)

I've made the following testing:
In the subclass, if I add someMethod(Number pSomeNumber):

  public void someMethod(String pSomeString)
  {
    // still don't use pSomeString, but no warnings raised
  }
  public void someMethod(Number pSomeNumber)
  {
    // still don't use pSomeNumber; warnnig is raised
  } 


then I get the warning for this new one, overloading the super class method with a different parameter type.
So it does display the warning in the subclass when the signature is different.

Let me think of it. I'll come back to you later on this one.

Regards,

Didier.
Jan Vervecken (...

Posts: 1,636
Registered: 10/29/98
Re: green analysis box : parameter not used
Posted: Oct 24, 2006 6:37 AM   in response to: Didier Laurent in response to: Didier Laurent
Click to report abuse...   Click to reply to this thread Reply
Thanks for your reply Didier.

Take all the time you need for this, I already have my "green analysis boxes". :)
(Maybe one day it will be possible to configure this more accurately in JDeveloper.)

regards
Jan
Jan Vervecken (...

Posts: 1,636
Registered: 10/29/98
Re: green analysis box : parameter not used
Posted: Oct 27, 2006 5:57 AM   in response to: Didier Laurent in response to: Didier Laurent
Click to report abuse...   Click to reply to this thread Reply
Didier

Thank your for the illustrated explanation in your blog post:
"Code Assist and Audit Rules"
http://blogs.oracle.com/Didier/2006/10/26#a124

regards
Jan
Didier Laurent

Posts: 611
Registered: 01/10/01
Re: green analysis box : parameter not used
Posted: Nov 14, 2006 12:54 PM   in response to: Jan Vervecken (... in response to: Jan Vervecken (...
Click to report abuse...   Click to reply to this thread Reply
Jan,

sorry for the lateness in logging the bug. It has been busy the last 2 weeks.

I logged Bug 5661368- AUDIT RULES: UNUSED PARAMETER NOT REPORTED FOR SUBCLASS
Bug should be visible in MetaLink as of tomorrow.

Regards,

Didier.
Legend
Guru Guru : 2500 - 1000000 pts
Expert Expert : 1000 - 2499 pts
Pro Pro : 500 - 999 pts
Journeyman Journeyman : 200 - 499 pts
Newbie Newbie : 0 - 199 pts
Oracle ACE Director
Oracle ACE Member
Oracle Employee ACE
Helpful Answer (5 pts)
Correct Answer (10 pts)

Point your RSS reader here for a feed of the latest messages in all forums