Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 354930 - Support for @Generated Annotation
Summary: Support for @Generated Annotation
Status: RESOLVED WONTFIX
Alias: None
Product: EMF
Classification: Modeling
Component: Tools (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Ed Merks CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-17 05:45 EDT by Johannes Utzig CLA
Modified: 2018-02-12 06:22 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Johannes Utzig CLA 2011-08-17 05:45:01 EDT
While the code generated by EMF is of great quality, if you use tools like Sonar (http://www.sonarsource.org/), having a lot of EMF generated code tends to break your quality metrics regarding cyclomatic complexity, code coverage and style violations.
Starting with Java 6, the API contains an @Generated annotation that can be used by code generators to mark classes and/or methods as auto generated. 
http://download.oracle.com/javase/6/docs/api/javax/annotation/Generated.html
Code analysis tools can use this annotations to ignore such classes/methods and therefore keep your metrics clean and accurate.

It would be terrific if the EMF code generator would have an option to add this @Generated annotation on top of, or instead of the currently used @generated.

As far as I know, most code analysis tools do not support this just yet, but it would be great if EMF would be ready once other tools start supporting it.
http://jira.codehaus.org/browse/SONAR-1042
Comment 1 Ed Merks CLA 2012-01-26 07:24:52 EST
Which things should all be marked this way?  Everywhere we have an @generated?   Does this marker on a class or interface imply anything about the contents being exclusively generated? I.e., can a @Generated interface contain things that aren't generated?
Comment 2 Johannes Utzig CLA 2012-01-26 15:21:28 EST
(In reply to comment #1)
> Which things should all be marked this way?  Everywhere we have an @generated? 
I would think so, yes. In regard to your question about the class/interface header, I would say at least members and methods.

>  Does this marker on a class or interface imply anything about the contents
> being exclusively generated? I.e., can a @Generated interface contain things
> that aren't generated?

A very good question indeed. Unfortunately, this is not clearly mentioned in the API-Doc, which makes it likely that different tools will interpret an @Generated on an interface/class differently. Some might just dismiss violations on the class declaration, while others might dismiss the class/interface completely.
Since it is not stated otherwise in the API-Doc, I assume that an @Generated class/interface can contain non-generated portions, but that doesn't mean that metric tools will behave that way.
Comment 3 Ed Merks CLA 2018-02-12 06:22:50 EST
I don't think there is sufficient demand for this in proportion to the effort involved.