PMD - pull_request #729
Annotations
2 errors and 1 warning
When doing a String.toLowerCase()/toUpperCase() call, use a Locale:
powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/UserAgentConfigurator.java#L112
When doing `String::toLowerCase()/toUpperCase()` conversions, use an explicit locale argument to specify the case
transformation rules.
Using `String::toLowerCase()` without arguments implicitly uses `Locale::getDefault()`.
The problem is that the default locale depends on the current JVM setup (and usually on the system in which
it is running). Using the system default may be exactly what you want (e.g. if you are manipulating strings
you got through standard input), but it may as well not be the case (e.g. if you are getting the string over
the network or a file, and the encoding is well-defined and independent of the environment). In the latter case,
using the default locale makes the case transformation brittle, as it may yield unexpected results on a machine
whose locale has other case translation rules. For example, in Turkish, the uppercase form of `i` is `İ` (U+0130,
not ASCII) and not `I` (U+0049) as in English.
The rule is intended to *force* developers to think about locales when dealing with strings. By taking a
conscious decision about the choice of locale at the time of writing, you reduce the risk of surprising
behaviour down the line, and communicate your intent to future readers.
UseLocaleWithCaseConversions (Priority: 1, Ruleset: Error Prone)
https://docs.pmd-code.org/snapshot/pmd_rules_java_errorprone.html#uselocalewithcaseconversions
|
Ensure that resources like this InputStream object are closed after use:
powertools-common/src/main/java/software/amazon/lambda/powertools/common/internal/UserAgentConfigurator.java#L65
Ensure that resources (like `java.sql.Connection`, `java.sql.Statement`, and `java.sql.ResultSet` objects
and any subtype of `java.lang.AutoCloseable`) are always closed after use.
Failing to do so might result in resource leaks.
Note: It suffices to configure the super type, e.g. `java.lang.AutoCloseable`, so that this rule automatically triggers
on any subtype (e.g. `java.io.FileInputStream`). Additionally specifying `java.sql.Connection` helps in detecting
the types, if the type resolution / auxclasspath is not correctly setup.
Note: Since PMD 6.16.0 the default value for the property `types` contains `java.lang.AutoCloseable` and detects
now cases where the standard `java.io.*Stream` classes are involved. In order to restore the old behaviour,
just remove "AutoCloseable" from the types.
CloseResource (Priority: 1, Ruleset: Error Prone)
https://docs.pmd-code.org/snapshot/pmd_rules_java_errorprone.html#closeresource
|
pmd_analyse
Error: Path Validation Error: Path(s) specified in the action for caching do(es) not exist, hence no cache is being saved.
|
Artifacts
Produced during runtime
Name | Size | Digest | |
---|---|---|---|
PMD Report
|
1.74 KB |
sha256:0b717e04c570f82357329552a63457171fc7a342c85b98a5fbad9555aa440971
|
|