-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Issue #9745: Added JavadocMethod inline return tag support #16605
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
@kkoutsilis , I am glad you are back. |
Thanks @romani. Update |
a295b06
to
0d01a5f
Compare
JavadocMethodCheck is not AST based, so robust implementation is unlikely possible to make. All such checks are waiting for complete reimplementation to use AST. So please find some good middle, where Check is doing validadtion but does not produce false-positives, and we will merge it. Users very angry on false-positives, but ok with false-negatives, as it does not block builds. |
cedb415
to
4023370
Compare
Hey @romani, CI is green apart from ci/circleci: no-error-xwiki, but I see this issue exists in the main pipeline. I believe this PR can be reviewed. What do you think? |
Xwiki is not related. Please trigger diff report for JavadocMethod |
Github, generate report for JavadocMethod |
Failed to download or process the specified configuration(s).
|
Github, generate report for JavadocMethod/all-examples-in-one |
Report for JavadocMethod/all-examples-in-one: |
@@ -256,13 +261,21 @@ public class JavadocMethodCheck extends AbstractCheck { | |||
/** Compiled regexp to match Javadoc tags with no argument. */ | |||
private static final Pattern MATCH_JAVADOC_NOARG = | |||
CommonUtil.createPattern("^\\s*(?>\\*|\\/\\*\\*)?\\s*@(return|see)\\s+\\S"); | |||
/** Compiled regexp to match Javadoc tags with no argument allowing inline return tag. */ | |||
private static final Pattern MATCH_JAVADOC_NOARG_INLINE_RETURN = | |||
CommonUtil.createPattern("^\\s*(?>\\*|\\/\\*\\*)?\\s*\\{?@(return|see)\\s+\\S"); |
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.
@see
tag is also covered by this regex, but the property name and javadoc mention only @return
tag. Does it make sense to give the option more generic name (e.g. allowInlineTags
), otherwise it is misleading? Or do we want to cover only the inline return tag?
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.
Hey @rdiachenko, thanks for the review. I believe we care about @return
tag only. I kept the see
in the regex just to be compatible with the MATCH_JAVASOC_NOARG
, but I don't believe it's used anywhere. If I am not mistaken the see
tag is completely optional and we don't do any checks about it, as there is no need.
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.
lgtm
GitHub, generate site |
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.
thanks a lot !!!
yes, better to keep it as property to allow users of different jdk to have behavior to match javadoc tool
@mahfouz72 , FYI. |
@kkoutsilis , in future PRs, please try to avoid Javadoc checks that are not based on AST, we plan to do this summer major update, so in ideal scenario we will be able to migrate all Javadoc checks that are regexp based to AST, so it will be a way less problems in support of them. |
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.
Looks good, two minor items:
/** | ||
* Setter to control whether to allow inline return tag. | ||
* | ||
* @param value a {@code Boolean} value |
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.
* @param value a {@code Boolean} value | |
* @param value a {@code boolean} value |
@@ -74,6 +74,9 @@ | |||
<description>Specify the access modifiers where Javadoc comments are | |||
checked.</description> | |||
</property> | |||
<property default-value="false" name="allowInlineReturn" type="boolean"> | |||
<description>Control whether to allow inline return tag.</description> |
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.
<description>Control whether to allow inline return tag.</description> | |
<description>Control whether to allow inline return tags.</description> |
Hey @nrmancuso, thanks for the review. Addressed your comments, feel free to have another look when you get the chance. |
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.
Good stuff! 🎉
Oh! Thank you so much @kkoutsilis!!!! |
Too bad it missed the 10.22.0 release by a few days. |
Happy to help. Hope this unblocks you 🙏 |
@JnRouvignac , |
@kkoutsilis , would you like us to recommend on next issue? |
If you have a priority to any issue I'm happy to have a look as always 🙂 |
src/main/java/com/puppycrawl/tools/checkstyle/checks/javadoc/JavadocMethodCheck.java
Show resolved
Hide resolved
Excellent! Thank you so much for the quick release! I can confirm this works for us, and the feature has benefited us a lot!!
I potentially noticed one small thing to improve ( Again, thank you so much @kkoutsilis! |
@romani I am looking for the next issue to pick up, any recommendations or preferences?? |
@kkoutsilis , please look at discord. |
Aims to close #9745
Added new
allowInlineReturn
property in JavadocMethodCheck to control whether to allow inline return tags in javadoc.Default. value is
false
to not break compatibility