Skip to content

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

Merged
merged 1 commit into from
Apr 1, 2025

Conversation

kkoutsilis
Copy link
Collaborator

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

@romani
Copy link
Member

romani commented Mar 19, 2025

@kkoutsilis , I am glad you are back.

@kkoutsilis
Copy link
Collaborator Author

kkoutsilis commented Mar 19, 2025

@kkoutsilis , I am glad you are back.

Thanks @romani.
FYI I realized that the regex will also match {@see ...} which should not be the case. Trying to fix this

Update
I don't see any tests or checks for @see tag, do we care about it here?

@kkoutsilis kkoutsilis force-pushed the 9745 branch 2 times, most recently from a295b06 to 0d01a5f Compare March 22, 2025 09:44
@romani
Copy link
Member

romani commented Mar 22, 2025

JavadocMethodCheck is not AST based, so robust implementation is unlikely possible to make.
We are ok with this.

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.

@kkoutsilis kkoutsilis force-pushed the 9745 branch 2 times, most recently from cedb415 to 4023370 Compare March 24, 2025 18:11
@kkoutsilis
Copy link
Collaborator Author

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?

@romani
Copy link
Member

romani commented Mar 24, 2025

Xwiki is not related.

Please trigger diff report for JavadocMethod

@kkoutsilis
Copy link
Collaborator Author

Github, generate report for JavadocMethod

Copy link
Contributor

Failed to download or process the specified configuration(s).
Error details:

Please ensure you've used one of the following commands correctly:

@romani
Copy link
Member

romani commented Mar 24, 2025

https://github.com/checkstyle/checkstyle/tree/master/.github/workflows#diff-report-by-configuration-at-test-configs-repository

You missed subfolder.

@kkoutsilis
Copy link
Collaborator Author

Github, generate report for JavadocMethod/all-examples-in-one

Copy link
Contributor

@@ -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");
Copy link
Contributor

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?

Copy link
Collaborator Author

@kkoutsilis kkoutsilis Mar 27, 2025

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.

Copy link
Contributor

@rdiachenko rdiachenko left a comment

Choose a reason for hiding this comment

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

lgtm

@rdiachenko rdiachenko assigned romani and unassigned rdiachenko Mar 27, 2025
@romani
Copy link
Member

romani commented Mar 29, 2025

GitHub, generate site

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.

thanks a lot !!!

yes, better to keep it as property to allow users of different jdk to have behavior to match javadoc tool

@romani romani requested a review from nrmancuso March 29, 2025 14:24
@romani romani assigned nrmancuso and unassigned romani Mar 29, 2025
@romani
Copy link
Member

romani commented Mar 29, 2025

@mahfouz72 , FYI.
interesting case on javadoc, different versions of it, and we should comply.
May be we need jdk version to be defined by user to let Checks understand what behavior is expected.

@romani
Copy link
Member

romani commented Mar 29, 2025

@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.

Copy link
Member

@nrmancuso nrmancuso left a 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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
* @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>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<description>Control whether to allow inline return tag.</description>
<description>Control whether to allow inline return tags.</description>

@kkoutsilis
Copy link
Collaborator Author

Hey @nrmancuso, thanks for the review. Addressed your comments, feel free to have another look when you get the chance.

Copy link
Member

@nrmancuso nrmancuso left a comment

Choose a reason for hiding this comment

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

Good stuff! 🎉

@nrmancuso nrmancuso merged commit 3f0fec8 into checkstyle:master Apr 1, 2025
114 of 115 checks passed
@kkoutsilis kkoutsilis deleted the 9745 branch April 1, 2025 13:56
@JnRouvignac
Copy link

Oh! Thank you so much @kkoutsilis!!!!

@JnRouvignac
Copy link

JnRouvignac commented Apr 2, 2025

Too bad it missed the 10.22.0 release by a few days.
Fine, I'll wait 😀

@kkoutsilis
Copy link
Collaborator Author

Oh! Thank you so much @kkoutsilis!!!!

Happy to help. Hope this unblocks you 🙏

@romani
Copy link
Member

romani commented Apr 2, 2025

@JnRouvignac ,
community not only doing fixed, they also automated release process, so we can release at any time, by any user request.
fix is released https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.23.0

@romani
Copy link
Member

romani commented Apr 2, 2025

@kkoutsilis , would you like us to recommend on next issue?

@kkoutsilis
Copy link
Collaborator Author

@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 🙂

@JnRouvignac
Copy link

@JnRouvignac , community not only doing fixed, they also automated release process, so we can release at any time, by any user request. fix is released https://github.com/checkstyle/checkstyle/releases/tag/checkstyle-10.23.0

Excellent! Thank you so much for the quick release!
Sorry for the late response, but I wanted to use it in my project before posting feedback here.

I can confirm this works for us, and the feature has benefited us a lot!!

255 files changed, 647 insertions(+), 2742 deletions(-)

I potentially noticed one small thing to improve ({@return} on multiple lines seem to require a final dot?), but I'll test some more and follow-up separately about it.

Again, thank you so much @kkoutsilis!

@kkoutsilis
Copy link
Collaborator Author

@kkoutsilis , would you like us to recommend on next issue?

@romani I am looking for the next issue to pick up, any recommendations or preferences??

@romani
Copy link
Member

romani commented Apr 28, 2025

@kkoutsilis , please look at discord.

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.

JavadocMethod: new property 'allowInlineReturn' to support for Javadoc return tag as inline
5 participants