Skip to content

Allow Javadoc tag description to begin with an acronym#471

Open
GollapudiSrikanth wants to merge 2 commits intospring-io:mainfrom
GollapudiSrikanth:srikanthgollapudi-allow-return-statements-begin-with-acronym
Open

Allow Javadoc tag description to begin with an acronym#471
GollapudiSrikanth wants to merge 2 commits intospring-io:mainfrom
GollapudiSrikanth:srikanthgollapudi-allow-return-statements-begin-with-acronym

Conversation

@GollapudiSrikanth
Copy link
Copy Markdown

This Change updates the case check to allow descriptions that start with 2 or more consecutive uppercase letters(acronym), while still rejecting single capitalized words like "The" or "Url"

Examples Allowed: "HTML","URL","JNI"

Closes #468

…cutive uppercase letters (e.g., "JNI", "HTML", "URL") instead of reporting a badCase violation. Single capitalized words are still rejected.

Closes spring-iogh-468

Signed-off-by: Venkata Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>
}

}
return upperCount >= 2;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will allow a description that starts with something like STRaNGE which is probably more than we need to allow. For now at least, we should only relax things to accept an upper-case first letter if all subsequent letters until the first space are also upper-case.

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;
Copy link
Copy Markdown
Contributor

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 – as SpringChecksTests now has two failures.

It also prevents startWithAcronym from being reached whenever the description starts with an upper-case character.

Copy link
Copy Markdown
Author

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.

if(description.length() > 0 || Character.isUpperCase(description.charAt(0))) {
return false;
}
return !startWithAcronym(description);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think this check belongs in a method named startsWithUppercase. I would either:

  • create a new method named something like hasCorrectCase that checks that the description either starts with an acronym or does not start with an upper-case character
  • update the code that currently calls startsWithUppercase to call both startsWithAcronym and startsWithUppercase

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The 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
Fixed the logic so that acronym detection is evaluated before the uppercase check, ensuring valid cases are not incorrectly rejected and existing tests pass
Refactored the logic to improve clarity by separating concerns

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.

image

Closes spring-iogh-468

Signed-off-by: Venkata Naga Sai Srikanth Gollapudi <42247688+GollapudiSrikanth@users.noreply.github.com>
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.

Allow @return statements to begin with an acronym

2 participants