pmd: fix #940 False positive on UnsynchronizedStaticDateFormatter
This commit is contained in:
parent
ad66153a2d
commit
f51e41b05c
@ -1,5 +1,6 @@
|
||||
????? ??, 2013 - 5.0.3:
|
||||
|
||||
Fixed bug 940: False positive on UnsynchronizedStaticDateFormatter
|
||||
Fixed bug 942: CheckResultSet False Positive and Negative
|
||||
Fixed bug 943: PreserveStackTrace false positive if a StringBuffer exists
|
||||
Fixed bug 945: PMD generates RuleSets it cannot read.
|
||||
|
@ -48,6 +48,11 @@ public class UnsynchronizedStaticDateFormatterRule extends AbstractJavaRule {
|
||||
if (n.getFirstParentOfType(ASTSynchronizedStatement.class) != null) {
|
||||
continue;
|
||||
}
|
||||
// ignore usages, that don't call a method.
|
||||
if (!n.getImage().contains(".")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ASTMethodDeclaration method = n.getFirstParentOfType(ASTMethodDeclaration.class);
|
||||
if (method != null && !method.isSynchronized()) {
|
||||
addViolation(data, n);
|
||||
|
@ -82,6 +82,21 @@ public class Foo {
|
||||
void bar() {
|
||||
sdf.format();
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
||||
<test-code>
|
||||
<description>#940 False positive on UnsynchronizedStaticDateFormatter</description>
|
||||
<expected-problems>0</expected-problems>
|
||||
<code><![CDATA[
|
||||
public class Test {
|
||||
private static final DateFormat enFormat = new SimpleDateFormat("EEEE MMMM d, yyyy 'at' hh':'mma", Locale.US);
|
||||
private static final DateFormat frFormat = new SimpleDateFormat("EEEE 'le' d MMMM yyyy 'à' HH'h'mm", Locale.CANADA_FRENCH);
|
||||
|
||||
protected DateFormat getDateFormat() {
|
||||
return getLang() == LangEnum.FR ? frFormat : enFormat;
|
||||
}
|
||||
}
|
||||
]]></code>
|
||||
</test-code>
|
||||
|
Loading…
x
Reference in New Issue
Block a user