Bug 222902 - [Javadoc] Missing description should not be warned in some cases
Summary: [Javadoc] Missing description should not be warned in some cases
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.4 M6   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 73352
Blocks: 227730
  Show dependency tree
 
Reported: 2008-03-16 15:03 EDT by Martin Oberhuber CLA
Modified: 2008-04-18 05:08 EDT (History)
12 users (show)

See Also:
frederic_fusier: review+


Attachments
Proposed fix and regression test (10.74 KB, patch)
2008-03-21 08:20 EDT, Jerome Lanneluc CLA
no flags Details | Diff
New proposed fix and regression test (14.42 KB, patch)
2008-03-21 12:06 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Oberhuber CLA 2008-03-16 15:03:21 EDT
+++ This bug was initially created as a clone of Bug #73352 +++

With bug 73352, a new feature was added to Eclipse 3.4M3 which allows to specify
Window > Preferences > Java > Compiler > Javadoc
  Malformed Javadoc comments: Warning
    Missing tag descriptions: Validate all tags

The problem with this setting is, that there are some Javadoc tags which usually do not have a description or argument, but still issue a warning:
  
  @generated
  @private

Especially the "@generated" tag is problematic since it is generated by EMF. It's a pity if I have to disable the whole "missing description" warning feature just because it overloads my Problems view with rogue warning due to EMF:
Javadoc: description expected after @generated

I think that the "Missing tag descriptions" warning feature should have a user-editable blacklist of Javadoc tags that it should not check (because users can add their own Javadoc tags and some of these may be designed not to take any description or arguments).
Comment 1 Jerome Lanneluc CLA 2008-03-19 08:25:42 EDT
This would require a new option to request a list of 'known' tags.
Changing the severity as enhancement as this requires a change in the API. However this is very unlikely that we will be able to provide this by M6 (next week) which is the last milestone for API changes.
Comment 2 Martin Oberhuber CLA 2008-03-19 08:35:16 EDT
What about a hardcoded list in a property file, for a start? - The problem with @generated is really annoying for me. I'm not sure what other tags could make it into that list, put having a file with the single @generated one would be a start.
Comment 3 Jerome Lanneluc CLA 2008-03-19 10:13:55 EDT
This would still be an API change since right now the spec says that it considers all tags. So we would have to clarify that a property file is used.

I'm afraid we currently don't have the resources to implement this. In the meantime, a workaround would be to filter the warnings in the Problems view:
Configure Contents > Description > Doesn't contain > @generated.
Would that work for you?
Comment 4 Martin Aeschlimann CLA 2008-03-19 20:32:10 EDT
Wouldn't it be better to only check for description on the Javadoc tags of the built-in tags? (the tags we know)

For user defined tags like @private or @generated we shouldn't make any assumtions.

I think we should change the spec on the API (it was added in 3.4) to say that all 'standard' tags are validated.
We can fix the code then also in M7, if this is complicated.
Comment 5 Martin Oberhuber CLA 2008-03-20 08:06:44 EDT
This sounds like a good suggestion. It's better to only check what's known rather than making assumptions about the general case.

As a definition of what is a standard tag, I'd propose taking all the block tags from http://java.sun.com/javase/6/docs/technotes/tools/windows/javadoc.html#javadoctags

Tag  	Introduced in JDK/SDK
@author 	1.0
@deprecated 	1.0
@exception 	1.0
@param 	        1.0
@return 	1.0
@see     	1.0
@serial 	1.2
@serialData 	1.2
@serialField 	1.2
@since 	        1.1
@throws 	1.2
@version 	1.0

With respect to the inline tags, does the code even check the inline tags currently? There are five which do expect an argument:

{@code} 	1.5
{@link} 	1.2
{@linkplain} 	1.4
{@literal} 	1.5
{@value} 	1.4

and two which do not take any argument:

{@docRoot} 	1.3
{@inheritDoc} 	1.4
Comment 6 Jerome Lanneluc CLA 2008-03-20 08:15:17 EDT
Trying to set the priority for this enhancement, can you tell me if the workaround suggested in comment 3 works for you?
Comment 7 Markus Keller CLA 2008-03-20 08:21:20 EDT
(In reply to comment #4)
+1. Should fix the API for M6 (implementation can wait until M7).

(In reply to comment #5)
> With respect to the inline tags, does the code even check the inline tags
> currently?

If it does, it has to accept both {@value} and {@value package.class#field} (since 1.5).
Comment 8 Martin Oberhuber CLA 2008-03-20 08:46:40 EDT
(In reply to comment #3)

> meantime, a workaround would be to filter the warnings in the Problems view:
> Configure Contents > Description > Doesn't contain > @generated.
> Would that work for you?

This is a nice idea, but the problem with this workaround is that I'm often using the text filter of the problems view for filtering other kinds of messages. Now it looks like since recently I'm able to save away my various kinds of filters for the problems view, but still I feel it's kinda clumsy having to switch.

Also, the workaround works for one tag ("@generated") only. It fails when I have multiple different kinds of tags that I'd need to filter away, because the text filter in the problems view does not support patterns or regular expressions (which would be a really nice enhancement, hint hint).

So - the workaround would be kind of ok in my concrete situation but I think that not changing the API specification to only apply to known tags is the right solution for now, and fixing the code later on.
Comment 9 Martin Oberhuber CLA 2008-03-20 08:47:51 EDT
(In reply to comment #8)
Oops that was a typo -- I'm *in favor* of changing the API spec now and fixing it afterwards.
Comment 10 Frederic Fusier CLA 2008-03-20 08:54:39 EDT
(In reply to comment #7)
> (In reply to comment #5)
> > With respect to the inline tags, does the code even check the inline tags
> > currently?
> 
Yes inline tags are also checked. 

> If it does, it has to accept both {@value} and {@value package.class#field}
> (since 1.5).
> 
The compiler accept {@value} for all compliances but only on static field javadoc comments and {@value package.class#field} on all javadoc comments but only if the compliance is >= 1.5...

But @value is not expected to have any description, so this bug does not seem relevant for this tag... Do not mix reference and description.
Comment 11 Jerome Lanneluc CLA 2008-03-20 09:02:19 EDT
I think the right approach would be to add a new option: JavaCore#COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_STANDARD_TAGS

Reusing JavaCore#COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_TAGS doesn't feel like a good idea, since "ALL" really means all tags.
Comment 12 Markus Keller CLA 2008-03-20 09:22:58 EDT
> JavaCore#COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_STANDARD_TAGS

The new option sounds good. But you should remove the COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_TAGS then, since it has only been introduced for 3.4 and is really of little use.

When you add support for user-supplied tag names in 3.5 or later, you could then add a fresh option to include those in the validation as well.
Comment 13 Martin Aeschlimann CLA 2008-03-20 17:27:15 EDT
> The new option sounds good. But you should remove the
> COMPILER_PB_MISSING_JAVADOC_TAG_DESCRIPTION_ALL_TAGS then, since it has only
> been introduced for 3.4 and is really of little use.

+1. As the bug shows, it doesn't seem that the 'all' option is very practical.
Comment 14 Jerome Lanneluc CLA 2008-03-21 08:20:56 EDT
Created attachment 93125 [details]
Proposed fix and regression test
Comment 15 Jerome Lanneluc CLA 2008-03-21 08:25:51 EDT
Frederic, can you please review the patch?
Comment 16 Jerome Lanneluc CLA 2008-03-21 12:06:02 EDT
Created attachment 93146 [details]
New proposed fix and regression test

Frederic noticed that the inline tags {@code} and {@literal} were not taken into account. Thanks Frederic. This patch fixes this problem and it adds more tests.
Comment 17 Jerome Lanneluc CLA 2008-03-22 07:40:10 EDT
Fix and test released for 3.4M6.
Entered bug 223553 against JDT/UI to adapt to the new constant.
Comment 18 Frederic Fusier CLA 2008-03-22 08:02:55 EDT
I was OK with the last patch (I forgot to set the review flag yesterday...)
Comment 19 David Audel CLA 2008-03-26 05:09:29 EDT
Verified for 3.4M6 using build I20080324-1300.
Comment 20 Martin Oberhuber CLA 2008-03-26 14:23:04 EDT
In terms of migration, what Strings do I need to change in my .settings/org.eclipse.jdt.core.prefs files?

I know that migration between milestones doesn't need to be supported officially, but knowing the stuff that I need to replace would simplify the process for me.
Comment 21 Frederic Fusier CLA 2008-03-26 14:47:13 EDT
(In reply to comment #20)
> In terms of migration, what Strings do I need to change in my
> .settings/org.eclipse.jdt.core.prefs files?
> 
> I know that migration between milestones doesn't need to be supported
> officially, but knowing the stuff that I need to replace would simplify the
> process for me.
> 
The value of org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription option has been changed from 'all_tags' to 'all_standard_tags'
Comment 22 Martin Oberhuber CLA 2008-03-27 10:59:01 EDT
Thanks.

I think that this was an important fix, especially taking into account the new Javadoc markup from API Tooling:
   1. @noimplement which applies to interfaces
   2. @noextend which applies to classes, interfaces and methods
   3. @noreference which applies to classes, methods and fields
   4. @noinstantiate which applies to classes 

See
http://wiki.eclipse.org/Api_Tooling