-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Issue #17158: fix invalid javadoc position for compact constructor #17249
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
Conversation
@romani I suppose these tests are old and I must write tests as we write them now for branch coverage purposes right? checkstyle/src/test/java/com/puppycrawl/tools/checkstyle/utils/BlockCommentPositionTest.java Lines 86 to 92 in 0b5361c
checkstyle/src/test/java/com/puppycrawl/tools/checkstyle/utils/BlockCommentPositionTest.java Lines 95 to 102 in 0b5361c
|
yes, we need coverage for new code in this PR thought Inputs and real Check usage. pure junit testing as you see it, does not contribute much to quality, as they migh be unrealistic and just test code for main code. One day in future we will convert all such pure unit testing to ent-to-end (Input based testing) |
428a453
to
1692554
Compare
Github, generate report for InvalidJavadocPosition/all-examples-in-one |
src/main/java/com/puppycrawl/tools/checkstyle/utils/BlockCommentPosition.java
Outdated
Show resolved
Hide resolved
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.
Just to be on the safe side, please also add this input case so we can ensure that no new false positive is introduced:
PS: If you use a canonical constructor instead of a compact constructor, the error goes away. Similarly, if you use public accessibility instead of package-protected, the error goes away.
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.
done
Report for InvalidJavadocPosition/all-examples-in-one: |
1692554
to
b4fcf7a
Compare
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.
items:
src/it/java/com/google/checkstyle/test/chapter7javadoc/rule711generalform/GeneralFormTest.java
Outdated
Show resolved
Hide resolved
src/main/java/com/puppycrawl/tools/checkstyle/utils/BlockCommentPosition.java
Outdated
Show resolved
Hide resolved
412876d
to
eeebf7b
Compare
Github, generate report for InvalidJavadocPosition/all-examples-in-one |
Report for InvalidJavadocPosition/all-examples-in-one: |
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.
Items
src/main/java/com/puppycrawl/tools/checkstyle/utils/BlockCommentPosition.java
Outdated
Show resolved
Hide resolved
eeebf7b
to
a57a335
Compare
Github, generate report for InvalidJavadocPosition/all-examples-in-one |
Report for InvalidJavadocPosition/all-examples-in-one: |
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 below suggested cases to the Check's input files too.
Mapping(String from, String to) { | ||
this.from = from; | ||
this.to = to; | ||
} |
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 also add a canonical constructor with public modifier
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.
done
@SizeType(max = 1) | ||
BindMount {} |
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 also use public keyword with compact constructor. Similarly for canonical constructor with annotation, create two cases - one with public modifier and other without any modifier.
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.
done
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.
can you also create a top-level record class? it is not necessary but it is always good to have all the cases covered
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.
done
@mohitsatr let's resume working on this PR. It is almost ready to merge, only few changes are required :) |
a57a335
to
4d44910
Compare
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 test extenstion
.../checks/javadoc/invalidjavadocposition/InputInvalidJavadocPositionOnCompactConstructors.java
Show resolved
Hide resolved
4d44910
to
3bd4c48
Compare
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.
Ok to merge
public record Mapping2(String to) { | ||
|
||
/** | ||
* The constructor for Mapping. | ||
* | ||
* @param to The source | ||
*/ | ||
@SizeType(max = 3) | ||
public Mapping2(String to) { | ||
this.to = to; | ||
} | ||
} |
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.
The input file is for compact constructors but we have used canonical constructor here. I would suggest to split examples into 2 files - one for compact constructors and second for canonical constructor.
Sorry for asking this but it will make the inputs more manageable and it will also simplify the process of adding more cases in future for other contributors.
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.
Sorry for asking this but it will make the inputs more manageable
no it does make sense.
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.
done
3bd4c48
to
c48f2e5
Compare
…or compact constructor
c48f2e5
to
7781f15
Compare
fixes #17158