[java] New rule: UseStandardCharsets#3193
Conversation
Generated by 🚫 Danger |
oowekyala
left a comment
There was a problem hiding this comment.
Thanks for the PR, this looks good! Please take a look at my comments to improve the details
|
Changes have been applied, based on review. Should have addressed all points raised. |
|
I'm not sure what to do of the pmd-test feedback though, seems to be raising issues about spring-framework somehow? Ah, the new check is finding two violations in Spring:
Working as intended it would seem? Does configuration need to be twaeked so that the check is not running by default out of the box? |
Looks good. Since this is a new rule, PMD finds now new violations, which is expected. The two new violations are valid cases for your new rule, so all is fine. |
|
I think this rule is a good candidate for the quickstart ruleset. @adangel wdyt? |
[java] New rule: UseStandardCharsets #3193
Describe the PR
(My first PR against PMD. Hopefully I did not screw up too badly :-D)
Starting with Java 7, StandardCharsets provides constants for common Charset objects, such as UTF-8.
Using the constants is less error prone, and can provide a small performance advantage compared to Charset.forName(...)
since no scan across the internal Charset caches is needed.
More discussion available in the linked issue
Related issues
Ready?
./mvnw clean verifypasses (checked automatically by travis)Unsure about the last point, the xml rule definition contains description and example, is there anything else to add?