Skip to content

Conversation

@aalmiray
Copy link
Contributor

@aalmiray aalmiray commented Oct 11, 2017

See https://issues.apache.org/jira/browse/GROOVY-8352

Retention policy is set to RUNTIMEin order to allow frameworks and libraries to have access to the new metadata.

There's a breaking change in Verifier, a protected method now returns MethodNode instead of void. This change was reviewed with @blackdrag and deemed the better solution among alternatives (such as duplicate method & deprecate old).

The JaCoCo team has done their part to prepare their project for this new annotation (see jacoco/jacoco#610).

*
* @author Andres Almiray
* @author Jochen Theodorou
* @author Mark Hoffmann
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's "Marc Hoffmann" 😉

Copy link
Contributor

@paulk-asert paulk-asert Oct 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we are mostly trying not to use @author tags these days - though we haven't made it mandatory.

Apache encourage removal of @author tags. It's not a mandated rule but they err on the side of wanting the whole community to own the whole codebase rather than potential contributors being put off by not wanting to touch a file "owned" by someone else. Git will tell us who the contributor was on a more fine-grained and accurate level than such tags anyway but obviously won't capture multiple authors committing under one of those names. Make sure anyone who has made a significant contribution is added into the pomconfigurer.gradle file.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulk-asert I'm completely o.k. with removing my name here at all.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marchof the pomconfigurer.gradle file is a good option too Marc! :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated PR by removing @author tags

@paulk-asert
Copy link
Contributor

I get the same failures locally as travis-ci. I haven't had time to fully investigate but it seems like we can get away without setting a source unit when we create little snippets by hand (in our test code for instance) so long as we don't have any annotations in those snippets. While I wonder whether checking for version >= jdk5 with isAnnotationCompatible is even needed anymore it might just be best to not add the Generated annotation if we don't find a source unit? What do you think?

@aalmiray
Copy link
Contributor Author

The test for @Generated was adapted from the one for @Immutable hence the check. @paulk-assert if you think it's worth removing then sure, I can remove it 😄 What other changes should be made to the test case?

if (!node.isDerivedFromGroovyObject()) node.addInterface(ClassHelper.make(GroovyObject.class));
FieldNode metaClassField = getMetaClassField(node);
AnnotationNode generatedAnnotation = new AnnotationNode(ClassHelper.make(GENERATED_ANNOTATION));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed a guard on adding the annotation to keep the build happy:

boolean shouldAnnotate = classNode.getModule().getContext() != null;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 small fixes added 😄

@marchof
Copy link

marchof commented Oct 12, 2017

FYI: The filter for the new annotation will be part of JaCoCo 0.8.0 release soon.

Copy link
Contributor

@paulk-asert paulk-asert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks okay to me for merging in master, GROOVY_2_6_X and GROOVY_2_5_X. I wonder whether we should have some guidance in the JavaDoc for Generated though on when we'd expect AST transformation writers to use this vs marking a method synthetic.

@asfgit asfgit closed this in 540826a Oct 16, 2017
@blackdrag
Copy link
Contributor

I pushed the branch. I do agree we should have a guideline for when to use it and when not. But I think we should first start using it and then decide what we want to advice

@cavdhut
Copy link

cavdhut commented Jan 24, 2018

I see it is not adding the @generated annotation to get/set methods generated by groovy for private variables. As a result code coverage reports are still not that accurate as code coverage reports still show get/set methods not covered.

@blackdrag
Copy link
Contributor

You mean for example in class X{def y} the getY and setY method?

@cavdhut
Copy link

cavdhut commented Jan 25, 2018

Yes..

@cavdhut
Copy link

cavdhut commented Jan 31, 2018

Any thoughts on above request to add @generated annotation for Groovy generated get/set methods for private variables?

@michelzanini
Copy link

Hi @aalmiray / @blackdrag ,

I wonder why the auto-generated setters and getters, as well as equals / hashcode are not also marked as @Generated.

I have the following class:
screen shot 2018-07-16 at 17 13 52

I am getting this coverage report:
screen shot 2018-07-16 at 17 13 43

I am using Groovy 2.5.1 and JaCoCo 0.8.1.

This class was supposed to have 100% code coverage.

Also something I get coverage saying I have not covered all branches of a line, but the line has just one branch:

screen shot 2018-07-16 at 17 19 09

What do you guys think?

@aalmiray
Copy link
Contributor Author

@michelzanini as of Groovy 2.5.2/3.0.0-alpha-3 getters/setters and many methods added by core AST transformations are not marked with @Generated. This will change in future releases. https://issues.apache.org/jira/browse/GROOVY-8765

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants