From 89bb73fc99bb2f4e01cca7bdc3de403c009219e2 Mon Sep 17 00:00:00 2001 From: Andreas Dangel Date: Sat, 8 Jun 2019 17:30:54 +0200 Subject: [PATCH] (doc) Update generated rule documentation --- docs/pages/pmd/rules/java/bestpractices.md | 4 +- docs/pages/pmd/rules/java/design.md | 4 +- docs/pages/pmd/rules/java/multithreading.md | 50 +++++++++++++++++---- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/docs/pages/pmd/rules/java/bestpractices.md b/docs/pages/pmd/rules/java/bestpractices.md index 4023ea302e..0ff9b5c2a4 100644 --- a/docs/pages/pmd/rules/java/bestpractices.md +++ b/docs/pages/pmd/rules/java/bestpractices.md @@ -1468,7 +1468,7 @@ public class Something { |Name|Default Value|Description|Multivalued| |----|-------------|-----------|-----------| -|ignoredAnnotations|lombok.Setter \| lombok.Getter \| lombok.Builder \| lombok.Data \| lombok.RequiredArgsConstructor \| lombok.AllArgsConstructor \| lombok.Value \| lombok.NoArgsConstructor \| java.lang.Deprecated \| javafx.fxml.FXML|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.| +|ignoredAnnotations|lombok.Setter \| lombok.Getter \| lombok.Builder \| lombok.Data \| lombok.RequiredArgsConstructor \| lombok.AllArgsConstructor \| lombok.Value \| lombok.NoArgsConstructor \| java.lang.Deprecated \| javafx.fxml.FXML \| lombok.experimental.Delegate|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.| **Use this rule with the default properties by just referencing it:** ``` xml @@ -1479,7 +1479,7 @@ public class Something { ``` xml - + ``` diff --git a/docs/pages/pmd/rules/java/design.md b/docs/pages/pmd/rules/java/design.md index b0647c24cd..3458d95fba 100644 --- a/docs/pages/pmd/rules/java/design.md +++ b/docs/pages/pmd/rules/java/design.md @@ -1779,7 +1779,7 @@ public class Foo { |Name|Default Value|Description|Multivalued| |----|-------------|-----------|-----------| -|ignoredAnnotations|lombok.Setter \| lombok.Getter \| lombok.Builder \| lombok.Data \| lombok.RequiredArgsConstructor \| lombok.AllArgsConstructor \| lombok.Value \| lombok.NoArgsConstructor|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.| +|ignoredAnnotations|lombok.Setter \| lombok.Getter \| lombok.Builder \| lombok.Data \| lombok.RequiredArgsConstructor \| lombok.AllArgsConstructor \| lombok.Value \| lombok.NoArgsConstructor \| lombok.experimental.Delegate|Fully qualified names of the annotation types that should be ignored by this rule|yes. Delimiter is '\|'.| |checkInnerClasses|false|Check inner classes|no| |disallowNotAssignment|false|Disallow violations where the first usage is not an assignment|no| @@ -1792,7 +1792,7 @@ public class Foo { ``` xml - + diff --git a/docs/pages/pmd/rules/java/multithreading.md b/docs/pages/pmd/rules/java/multithreading.md index 256bb3e149..34e0e7275d 100644 --- a/docs/pages/pmd/rules/java/multithreading.md +++ b/docs/pages/pmd/rules/java/multithreading.md @@ -293,7 +293,7 @@ public static Foo getFoo() { SimpleDateFormat instances are not synchronized. Sun recommends using separate format instances for each thread. If multiple threads must access a static formatter, the formatter must be -synchronized either on method or block level. +synchronized on block level. This rule has been deprecated in favor of the rule {% rule UnsynchronizedStaticFormatter %}. @@ -307,17 +307,34 @@ public class Foo { void bar() { sdf.format(); // poor, no thread-safety } - static synchronized void foo() { - sdf.format(); // preferred + void foo() { + synchronized (sdf) { // preferred + sdf.format(); + } } } ``` -**Use this rule by referencing it:** +**This rule has the following properties:** + +|Name|Default Value|Description|Multivalued| +|----|-------------|-----------|-----------| +|allowMethodLevelSynchronization|false|If true, method level synchronization is allowed as well as synchronized block. Otherwise only synchronized blocks are allowed.|no| + +**Use this rule with the default properties by just referencing it:** ``` xml ``` +**Use this rule and customize it:** +``` xml + + + + + +``` + ## UnsynchronizedStaticFormatter **Since:** PMD 6.11.0 @@ -327,7 +344,7 @@ public class Foo { Instances of `java.text.Format` are generally not synchronized. Sun recommends using separate format instances for each thread. If multiple threads must access a static formatter, the formatter must be -synchronized either on method or block level. +synchronized on block level. **This rule is defined by the following Java class:** [net.sourceforge.pmd.lang.java.rule.multithreading.UnsynchronizedStaticFormatterRule](https://github.com/pmd/pmd/blob/master/pmd-java/src/main/java/net/sourceforge/pmd/lang/java/rule/multithreading/UnsynchronizedStaticFormatterRule.java) @@ -339,17 +356,34 @@ public class Foo { void bar() { sdf.format(); // poor, no thread-safety } - static synchronized void foo() { - sdf.format(); // preferred + void foo() { + synchronized (sdf) { // preferred + sdf.format(); + } } } ``` -**Use this rule by referencing it:** +**This rule has the following properties:** + +|Name|Default Value|Description|Multivalued| +|----|-------------|-----------|-----------| +|allowMethodLevelSynchronization|false|If true, method level synchronization is allowed as well as synchronized block. Otherwise only synchronized blocks are allowed.|no| + +**Use this rule with the default properties by just referencing it:** ``` xml ``` +**Use this rule and customize it:** +``` xml + + + + + +``` + ## UseConcurrentHashMap **Since:** PMD 4.2.6