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
Issue #3440: Added new check for verifying that annotation located on same line with its target #4895
Conversation
2cd4673
to
ce7526a
Compare
Codecov Report
@@ Coverage Diff @@
## master #4895 +/- ##
======================================
Coverage 100% 100%
======================================
Files 293 294 +1
Lines 15897 15925 +28
Branches 3606 3614 +8
======================================
+ Hits 15897 15925 +28
Continue to review full report at Codecov.
|
There was a problem hiding this 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. | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
src/xdocs/config_annotation.xml
Outdated
@@ -228,6 +228,111 @@ public void test(@MyAnnotation String s) { // OK | |||
</subsection> | |||
</section> | |||
|
|||
<section name="AnnotationOnSameLine"> | |||
<subsection name="Description"> | |||
<p>Since Checkstyle 8.1</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
8.2 as minimum
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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, ....).
There was a problem hiding this comment.
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"), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
src/xdocs/config_annotation.xml
Outdated
<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> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
ce7526a
to
44d75dd
Compare
@kazachka Shippable failed.
|
@kazachka , please make sure that there is 100% coverage on your Check, in pitest report. |
44d75dd
to
941570c
Compare
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> |
There was a problem hiding this comment.
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.*
?
There was a problem hiding this comment.
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
@kazachka , please provide testing report of this Check over multiple projects, please use our checkstyle-tester tool |
There was a problem hiding this 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
src/xdocs/config_annotation.xml
Outdated
<subsection name="Description"> | ||
<p>Since Checkstyle 8.2</p> | ||
<p> | ||
Check annotation located on same line with its target. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this 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; |
There was a problem hiding this comment.
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();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
src/xdocs/checks.xml
Outdated
@@ -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> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to javadoc text
src/xdocs/config_annotation.xml
Outdated
<subsection name="Description"> | ||
<p>Since Checkstyle 8.2</p> | ||
<p> | ||
Check annotation located on same line with its target. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to javadoc text
…located on the same line with its target
941570c
to
91144e4
Compare
As soon as TC passed , we could merge. but lets wait for TC to finish. |
Issue #3440
Added new check for verifying that annotation located on same line with its target.