HDDS-14918. Enable PMD rules StringToString, UseArraysAsList and UseIndexOfChar#9999
Open
ptlrs wants to merge 4 commits intoapache:masterfrom
Open
HDDS-14918. Enable PMD rules StringToString, UseArraysAsList and UseIndexOfChar#9999ptlrs wants to merge 4 commits intoapache:masterfrom
ptlrs wants to merge 4 commits intoapache:masterfrom
Conversation
adoroszlai
reviewed
Mar 29, 2026
Contributor
adoroszlai
left a comment
There was a problem hiding this comment.
Thanks @ptlrs for the patch.
Comment on lines
+46
to
+48
| <rule ref="category/java/performance.xml/StringToString"/> | ||
| <rule ref="category/java/performance.xml/UseArraysAsList"/> | ||
| <rule ref="category/java/performance.xml/UseIndexOfChar"/> |
Contributor
There was a problem hiding this comment.
nit: please keep alphabetical order, which makes it easier to spot enabled rules at a glance
| String attName = attr.getName(); | ||
| if (!"modelerType".equals(attName)) { | ||
| if (attName.indexOf("=") < 0 && attName.indexOf(":") < 0 && attName.indexOf(" ") < 0) { | ||
| if (!attName.contains("=") && !attName.contains(":") && !attName.contains(" ")) { |
Contributor
There was a problem hiding this comment.
nit: Replace indexOf(String) with indexOf(int), not contains(String), for efficiency.
Comment on lines
+234
to
+236
| cause = cause.substring(cause.indexOf(':') + 2); | ||
| remote = new RemoteException(cause.substring(0, cause.indexOf(':')), | ||
| cause.substring(cause.indexOf(':') + 1)); |
Contributor
There was a problem hiding this comment.
nit: store cause.indexOf(':')
Comment on lines
+118
to
+120
| String trashDirectory = (keyName.contains("/") | ||
| ? new Path(userTrashCurrent, keyName.substring(0, | ||
| keyName.lastIndexOf("/"))) | ||
| keyName.lastIndexOf('/'))) |
Contributor
There was a problem hiding this comment.
nit: store keyName.lastIndexOf('/') to replace contains("/")
Comment on lines
+147
to
+148
| if (host.contains(":")) { | ||
| return host.substring(0, host.lastIndexOf(":")); | ||
| return host.substring(0, host.lastIndexOf(':')); |
Contributor
There was a problem hiding this comment.
nit: store lastIndexOf and replace contains
| int idx = name.indexOf('@'); | ||
| if (idx != -1) { | ||
| pidStr = name.substring(0, name.indexOf("@")); | ||
| pidStr = name.substring(0, name.indexOf('@')); |
Contributor
There was a problem hiding this comment.
Suggested change
| pidStr = name.substring(0, name.indexOf('@')); | |
| pidStr = name.substring(0, idx); |
Contributor
Author
|
Thanks for the review @adoroszlai. I have pushed the fixes. |
adoroszlai
approved these changes
Mar 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
This PR enabled the following PMD rules:
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-14918
How was this patch tested?
CI: https://github.com/ptlrs/ozone/actions/runs/23707401043