-
Notifications
You must be signed in to change notification settings - Fork 126
Allow Javadoc tag description to begin with an acronym #471
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| * Checks that the javadoc comments follow Spring conventions. | ||
| * | ||
| * @author Phillip Webb | ||
| * @author Venkata Naga Sai Srikanth Gollapudi | ||
| */ | ||
| public class SpringJavadocCheck extends AbstractSpringCheck { | ||
|
|
||
|
|
@@ -245,9 +246,27 @@ private void checkAnnotationFieldJavaDoc(DetailAST ast, TextBlock javadoc) { | |
| } | ||
|
|
||
| private boolean startsWithUppercase(String description) { | ||
| return description.length() > 0 && Character.isUpperCase(description.charAt(0)); | ||
| if(description.length() > 0 || Character.isUpperCase(description.charAt(0))) { | ||
| return false; | ||
| } | ||
| return !startWithAcronym(description); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this check belongs in a method named
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the detailed feedback — this was really helpful. I’ve updated the implementation to address all the points: Refined the acronym check to ensure that only fully upper-case words (e.g. URL, HTML, JNI) are allowed, avoiding cases like STRaNGE I’ve also run the full test suite on this branch and confirmed everything is passing Please let me know if you'd prefer a different structure or further refinements.
|
||
| } | ||
|
|
||
| private boolean startWithAcronym(String description) { | ||
| int upperCount = 0; | ||
| for (int i = 0; i < description.length(); i++) { | ||
| char ch= description.charAt(i); | ||
| if (Character.isUpperCase(ch)) { | ||
| upperCount++; | ||
| } | ||
| else { | ||
| break; | ||
| } | ||
|
|
||
| } | ||
| return upperCount >= 2; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will allow a description that starts with something like |
||
| } | ||
|
|
||
| private void checkForNonJavadocComments(TextBlock block) { | ||
| if (block == null) { | ||
| return; | ||
|
|
||

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 logic's now wrong as a description that starts with an upper-case character will return
false. This is evident if you run the module's tests – something that you should do before submitting a PR – asSpringChecksTestsnow has two failures.It also prevents
startWithAcronymfrom being reached whenever the description starts with an upper-case character.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 for pointing this out — you're right. I ran the tests on my local main branch but missed running them against my PR branch after the changes.