Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #3440: Added new check for verifying that annotation located on same line with its target #4895

Merged
merged 1 commit into from Aug 28, 2017

Conversation

kazachka
Copy link
Contributor

@kazachka kazachka commented Aug 3, 2017

Issue #3440

Added new check for verifying that annotation located on same line with its target.

@kazachka kazachka force-pushed the single-line-annotation-check branch from 2cd4673 to ce7526a Compare August 3, 2017 20:44
@codecov-io
Copy link

codecov-io commented Aug 3, 2017

Codecov Report

Merging #4895 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #4895   +/-   ##
======================================
  Coverage     100%    100%           
======================================
  Files         293     294    +1     
  Lines       15897   15925   +28     
  Branches     3606    3614    +8     
======================================
+ Hits        15897   15925   +28
Impacted Files Coverage Δ
...e/checks/annotation/AnnotationOnSameLineCheck.java 100% <100%> (ø)
...pycrawl/tools/checkstyle/PackageObjectFactory.java 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e51f945...91144e4. Read the comment docs.

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

please add your Check to
https://github.com/checkstyle/checkstyle/blob/master/pom.xml#L1633 (shippable.yml use such profiles)
and make sure mutation level is 100% for your Check.

items to improve:

annotation.trailing.comma.missing=Annotation array values must contain trailing comma.
annotation.trailing.comma.present=Annotation array values cannot contain trailing comma.
javadoc.duplicateTag=Duplicate {0} tag.
javadoc.missing=Missing a Javadoc comment.
suppressed.warning.not.allowed=The warning ''{0}'' cannot be suppressed at this location.
tag.not.valid.on=The Javadoc {0} tag is not valid at this location.

Copy link
Member

Choose a reason for hiding this comment

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

please avoid non required changes in such big update to code. In other files too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

deleted
now there is different empty lines in different language files

@@ -228,6 +228,111 @@ public void test(&#64;MyAnnotation String s) { // OK
</subsection>
</section>

<section name="AnnotationOnSameLine">
<subsection name="Description">
<p>Since Checkstyle 8.1</p>
Copy link
Member

Choose a reason for hiding this comment

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

8.2 as minimum

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


@Annotation
@SomeClass.Annotation
public int getX() {
Copy link
Member

Choose a reason for hiding this comment

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

please provide more tests, 2 test cases if not enough.
Please reuse all cases that are mentioned in issue. Please provide more tests for all tokens(methods, fields, classes, interfaces, ....).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added cases from issue and for all of tokens except of DOT (i can't find any usage of annotation with this token)

final DefaultConfiguration config = createModuleConfig(AnnotationOnSameLineCheck.class);
final String[] expected = {
"9: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "Annotation"),
"10: " + getCheckMessage(MSG_KEY_ANNOTATION_ON_SAME_LINE, "SomeClass"),
Copy link
Member

Choose a reason for hiding this comment

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

Isn't annotation name Annotation and not SomeClass?
If I wrote out java.lang.Override, annotation name isn't java, it is Override.
Please add java.lang.Override as an example too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Method updated.
Note that i copy it from AnnotationLocationCheck, so AnnotationLocation can wrote "SomeClass" instead "Annotation".
Added java.lang.Deprecated as example.

<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#CTOR_DEF">CTOR_DEF</a>,
<a href="apidocs/com/puppycrawl/tools/checkstyle/api/TokenTypes.html#VARIABLE_DEF">VARIABLE_DEF</a>.
</td>
<td>8.1</td>
Copy link
Member

Choose a reason for hiding this comment

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

should be 8.2 too.

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

@kazachka kazachka force-pushed the single-line-annotation-check branch from ce7526a to 44d75dd Compare August 12, 2017 19:15
@rnveach
Copy link
Member

rnveach commented Aug 13, 2017

@kazachka Shippable failed.

-Ppitest-checks-annotation
[ERROR] Failed to execute goal org.pitest:pitest-maven:1.2.2:mutationCoverage (default-cli) on project checkstyle: Mutation score of 93 is below threshold of 100 -> [Help 1]

@romani
Copy link
Member

romani commented Aug 17, 2017

@kazachka , please make sure that there is 100% coverage on your Check, in pitest report.

@kazachka kazachka force-pushed the single-line-annotation-check branch from 44d75dd to 941570c Compare August 18, 2017 16:52
@kazachka
Copy link
Contributor Author

I just forgot to add test to pitest configuration in pom.xml

@@ -1675,6 +1675,7 @@
<configuration>
<targetClasses>
<param>com.puppycrawl.tools.checkstyle.checks.annotation.AnnotationLocationCheck</param>
Copy link
Member

Choose a reason for hiding this comment

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

@romani Why wasn't this com.puppycrawl.tools.checkstyle.checks.annotation.*?

Copy link
Member

Choose a reason for hiding this comment

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

because of hcoles/pitest#368

@romani
Copy link
Member

romani commented Aug 24, 2017

@kazachka , please provide testing report of this Check over multiple projects, please use our checkstyle-tester tool

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

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

Last item to improve.

@rnveach , please finish your review

<subsection name="Description">
<p>Since Checkstyle 8.2</p>
<p>
Check annotation located on same line with its target.
Copy link
Member

Choose a reason for hiding this comment

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

We need make a note that this Check is not a good practice, but some style guides use it.

Copy link
Member

Choose a reason for hiding this comment

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

Make sure this note is in the check's Javadoc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note added to both xdocs and javadoc

Copy link
Member

@rnveach rnveach left a comment

Choose a reason for hiding this comment

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

I don't see anything else right now.

* @return node that is next to given
*/
private static DetailAST getNextNode(DetailAST node) {
final DetailAST nextNode;
Copy link
Member

Choose a reason for hiding this comment

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

All your other forms of writing this was writing the assignment with the standard one, and than change it's assignment if it was null. Why did you change it here?

DetailAST nextNode = node.getNextSibling();
if (nextNode == null) {
    nextNode = node.getParent().getNextSibling();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@@ -48,6 +48,10 @@
<td>Check location of annotation on language elements.</td>
</tr>
<tr>
<td><a href="config_annotation.html#AnnotationOnSameLine">AnnotationOnSameLine</a></td>
<td>Check annotation on language elements is on same line with its target element.</td>
Copy link
Member

Choose a reason for hiding this comment

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

Why isn't this the same text as in the check in config_annotation or in the main Javadoc for the check?

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 to javadoc text

<subsection name="Description">
<p>Since Checkstyle 8.2</p>
<p>
Check annotation located on same line with its target.
Copy link
Member

Choose a reason for hiding this comment

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

Please make this description the same the check's javadoc.

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 to javadoc text

@kazachka kazachka force-pushed the single-line-annotation-check branch from 941570c to 91144e4 Compare August 27, 2017 21:08
@kazachka
Copy link
Contributor Author

@romani
Copy link
Member

romani commented Aug 28, 2017

As soon as TC passed , we could merge. but lets wait for TC to finish.

@romani romani merged commit 76b6f99 into checkstyle:master Aug 28, 2017
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.

None yet

4 participants