Skip to content

Commit 4342c35

Browse files
committed
Small descriptive improvements
Fixes xdev-software/java-setup-template#2
1 parent 53e5c31 commit 4342c35

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

.config/pmd/java/ruleset.xml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@
213213
message="StringBuilder/StringBuffer should not be used"
214214
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
215215
<description>
216-
Usually all cases where `StringBuilder` (or the outdated `StringBuffer`) is used are either due to confusing (legacy) logic or may be replaced by a simpler string concatenation.
216+
Usually all cases where `StringBuilder` (or the outdated `StringBuffer`) is used are either due to confusing (legacy) logic or in situations where it may be easily replaced by a simpler string concatenation.
217217

218218
Solution:
219219
* Do not use `StringBuffer` because it's thread-safe and usually this is not needed
220-
* If `StringBuilder` is only used in a simple method (like `toString`) and is effectively inlined: Use a simpler string concatenation (`"a" + x + "b"`). This will be optimized by the Java compiler internally.
220+
* If `StringBuilder` is only used in a simple method (like `toString`) and is effectively inlined: Use a simpler string concatenation (`"a" + x + "b"`). This will be [optimized by the Java compiler internally](https://docs.oracle.com/javase/specs/jls/se25/html/jls-15.html#jls-15.18.1).
221221
* In all other cases:
222222
* Check what is happening and if it makes ANY sense! If for example a CSV file is built here consider using a proper library instead!
223223
* Abstract the Strings into a DTO, join them together using a collection (or `StringJoiner`) or use Java's Streaming API instead
@@ -239,8 +239,8 @@ Solution:
239239
message="Setters of java.lang.System should not be called unless really needed"
240240
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule">
241241
<description>
242-
Calling setters of java.lang.System usually indicates bad design and likely causes unexpected behavior.
243-
For example, it may break when multiple Threads are setting the value.
242+
Calling setters of `java.lang.System` usually indicates bad design and likely causes unexpected behavior.
243+
For example, it may break when multiple Threads are working with the same value.
244244
It may also overwrite user defined options or properties.
245245

246246
Try to pass the value only to the place where it's really needed and use it there accordingly.
@@ -352,7 +352,8 @@ You can suppress this warning when you properly sanitized the name.
352352
Nearly every known usage of (Java) Object Deserialization has resulted in [a security vulnerability](https://cloud.google.com/blog/topics/threat-intelligence/hunting-deserialization-exploits?hl=en).
353353
Vulnerabilities are so common that there are [dedicated projects for exploit payload generation](https://github.com/frohoff/ysoserial).
354354

355-
Java Object Serialization may also fail to deserialize when the underlying classes are changed.
355+
Java Object Serialization may also fail to deserialize properly when the underlying classes are changed.
356+
This can result in unexpected crashes when outdated data is deserialized.
356357

357358
Use proven data interchange formats like JSON instead.
358359
</description>
@@ -374,7 +375,8 @@ Use proven data interchange formats like JSON instead.
374375
<rule name="VaadinNativeHTMLIsUnsafe"
375376
language="java"
376377
message="Unescaped native HTML is unsafe and will result in XSS vulnerabilities"
377-
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule" >
378+
class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
379+
externalInfoUrl="https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML">
378380
<description>
379381
Do not use native HTML! Use Vaadin layouts and components to create required structure.
380382
If you are 100% sure that you escaped the value properly and you have no better options you can suppress this.

0 commit comments

Comments
 (0)