Merge branch 'bug-1556' into pmd/5.5.x

This commit is contained in:
Andreas Dangel
2017-01-08 13:58:13 +01:00
3 changed files with 32 additions and 8 deletions

View File

@ -709,8 +709,8 @@ public class Foo {
</rule>
<rule name="UseLocaleWithCaseConversions"
language="java"
since="2.0"
language="java"
since="2.0"
message="When doing a String.toLowerCase()/toUpperCase() call, use a Locale"
class="net.sourceforge.pmd.lang.rule.XPathRule"
externalInfoUrl="${pmd.website.baseurl}/rules/java/design.html#UseLocaleWithCaseConversions">
@ -724,12 +724,19 @@ have unusual conventions, i.e. Turkish.
<value>
<![CDATA[
//PrimaryExpression
[PrimaryPrefix/Name
[ends-with(@Image, 'toLowerCase') or ends-with(@Image,
'toUpperCase')]
]
[PrimarySuffix[position() = 1]/Arguments[@ArgumentCount=0]]
]]>
[
PrimaryPrefix
[Name[ends-with(@Image, 'toLowerCase') or ends-with(@Image, 'toUpperCase')]]
[following-sibling::PrimarySuffix[position() = 1]/Arguments[@ArgumentCount=0]]
or
PrimarySuffix
[ends-with(@Image, 'toLowerCase') or ends-with(@Image, 'toUpperCase')]
[following-sibling::PrimarySuffix[position() = 1]/Arguments[@ArgumentCount=0]]
]
[not(PrimaryPrefix/Name[ends-with(@Image, 'toHexString')])]
]]>
</value>
</property>
</properties>

View File

@ -59,4 +59,20 @@ public class Foo {
}
]]></code>
</test-code>
<test-code>
<description>#1556 [java] UseLocaleWithCaseConversions does not works with `ResultSet` (false negative)</description>
<expected-problems>1</expected-problems>
<code><![CDATA[
import java.sql.*;
final class Test {
private Test() { }
public static String foo(ResultSet r) throws SQLException {
return r.getString("bar").toLowerCase();
}
}
]]></code>
</test-code>
</test-data>

View File

@ -184,6 +184,7 @@ to avoid XSS attacks.
* [#1545](https://sourceforge.net/p/pmd/bugs/1545/): \[java] Symbol Table fails to resolve inner classes
* java-design
* [#1552](https://sourceforge.net/p/pmd/bugs/1552/): \[java] MissingBreakInSwitch - False positive for continue
* [#1556](https://sourceforge.net/p/pmd/bugs/1556/): \[java] UseLocaleWithCaseConversions does not works with `ResultSet` (false negative)
* [#177](https://github.com/pmd/pmd/issues/177): \[java] SingularField with lambdas as final fields
* java-imports
* [#1546](https://sourceforge.net/p/pmd/bugs/1546/): \[java] UnnecessaryFullyQualifiedNameRule doesn't take into consideration conflict resolution