Apply suggestions from code review
This commit is contained in:
@ -30,7 +30,7 @@ needs mutual exclusion will be locked.
|
||||
<![CDATA[
|
||||
public class Foo {
|
||||
// Try to avoid this:
|
||||
synchronized void bar() {
|
||||
synchronized void foo() {
|
||||
// code, that doesn't need synchronization
|
||||
// ...
|
||||
// code, that requires synchronization
|
||||
@ -63,7 +63,7 @@ public class Foo {
|
||||
}
|
||||
|
||||
// Prefer this:
|
||||
private static Lock CLS_LOCK = new ReentrantLock();
|
||||
private static Lock CLASS_LOCK = new ReentrantLock();
|
||||
|
||||
static void barStatic() {
|
||||
// code, that doesn't need synchronization
|
||||
|
@ -5,7 +5,7 @@
|
||||
xsi:schemaLocation="http://pmd.sourceforge.net/rule-tests http://pmd.sourceforge.net/rule-tests_1_0_0.xsd">
|
||||
|
||||
<test-code>
|
||||
<description>TEST1</description>
|
||||
<description>Synchronized block in instance method</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Foo {
|
||||
@ -17,7 +17,7 @@ public class Foo {
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>#991 AvoidSynchronizedStatement for static methods</description>
|
||||
<description>Synchronized block in static methods</description>
|
||||
<expected-problems>1</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Test {
|
||||
@ -26,6 +26,17 @@ public class Test {
|
||||
// only a block is synchronized on Test.class
|
||||
}
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>synchronized methods are not flagged - we have a separate rule AvoidSynchronizedAtMethodLevel for that</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Test {
|
||||
public synchronized void foo() {}
|
||||
public static synchronized void fooStatic() {}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Reference in New Issue
Block a user