-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
[java] Deprecated CommentUtil, move implementation to AST Comment #1198
Conversation
That was a interesting rabbit whole 😄 pmd/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/documentation/AbstractCommentRule.java Line 96 in a89d541
So interesting is: FormalComment has basic support for javadoc tags: In Comment we parse the javadoc and add JavadocElement nodes as children... I moved the code into FormalComment. |
* @return List of lines of the comments | ||
*/ | ||
private List<String> multiLinesIn() { | ||
String[] lines = getImage().split("\\R"); |
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.
support for the line break matcher is Java8+ only. We can however use the extended version of this:
\u000D\u000A|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029]
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.
Oh, didn't know that...
boolean foundFirstNonEmptyLine = false; | ||
for (String line : lines) { | ||
if (StringUtils.isNoneBlank(line)) { | ||
// new non-empty line: add all previous empty lines occurred before |
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.
isNoneBlank
doesn't check the line is not empty, but actually if not a single character is a whitespace. So, "this is my comment" will fail this check for having 3 whitespaces. Is this really what you expect?
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.
I guess, I wanted to use isNotBlank
- isNoneBlank is the same, but for multiple lines (it accepts a vararg ... String). So, the plural here would refer to multiple lines, not to multiple characters...
private void findJavadocs(String commentText) { | ||
Collection<JavadocElement> kids = new ArrayList<>(); | ||
|
||
Map<String, Integer> tags = CommentUtil.javadocTagsIn(commentText); |
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.
shouldn't we avoid internal usage of CommentUtil
as we are deprecating it?
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.
I've missed that...
Fixes #1174
Work in progress - this is missing: