Fixed bug 1378358 - StringInstantiation no longer throws ClassCastExceptions on certain allocation patterns. Thanks to Bruce Kelly for the report!
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@4054 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -10,6 +10,7 @@ Fixed bug 1373510 - UseAssertSameInsteadOfAssertTrue no longer has a typo in its
|
||||
Fixed bug 1375290 - @SuppressWarnings annotations are now implemented correctly; they accept one blank argument to suppress all warnings.
|
||||
Fixed bug 1376760 - InefficientStringBuffering no longer throws a NullPointerException when processing certain expressions.
|
||||
Fixed bug 1376756 - UselessOverridingMethod no longer throws an exception on overloaded methods.
|
||||
Fixed bug 1378358 - StringInstantiation no longer throws ClassCastExceptions on certain allocation patterns.
|
||||
Fixed a bug in UseStringBufferLength; it no longers fails with an exception on expressions like StringBuffer.toString.equals(x)
|
||||
Partially fixed bug 1371753 - UnnecessaryLocalBeforeReturn message now reflects the fact that that rule flags all types
|
||||
Modified renderers to support disabling printing of suppressed warnings. Introduced a new AbstractRenderer class that all Renderers can extends to get the current behavior - that is, suppressed violations are printed.
|
||||
|
@ -8,6 +8,7 @@ import net.sourceforge.pmd.ast.ASTClassOrInterfaceType;
|
||||
import net.sourceforge.pmd.ast.ASTExpression;
|
||||
import net.sourceforge.pmd.ast.ASTName;
|
||||
import net.sourceforge.pmd.symboltable.VariableNameDeclaration;
|
||||
import net.sourceforge.pmd.symboltable.NameDeclaration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -39,9 +40,14 @@ public class StringInstantiation extends AbstractRule {
|
||||
return data;
|
||||
}
|
||||
|
||||
VariableNameDeclaration nd = (VariableNameDeclaration)name.getNameDeclaration();
|
||||
NameDeclaration nd = (NameDeclaration)name.getNameDeclaration();
|
||||
if (!(nd instanceof VariableNameDeclaration)) {
|
||||
return data;
|
||||
}
|
||||
|
||||
VariableNameDeclaration vnd = (VariableNameDeclaration)nd;
|
||||
// nd == null in cases like: return new String("foo");
|
||||
if (nd == null || nd.getTypeImage().equals("String")) {
|
||||
if (vnd == null || vnd.getTypeImage().equals("String")) {
|
||||
addViolation(data, node);
|
||||
|
||||
}
|
||||
|
@ -45,8 +45,8 @@
|
||||
</subsection>
|
||||
<subsection name="Contributors">
|
||||
<ul>
|
||||
<li>Bruce Kelly - bug report 1378358 for StringInstantiation, bug report 1376756 for UselessOverridingMethod, bug report 1376760 for InefficientStringBuffering</li>
|
||||
<li>Isaac Babsky - tweak for pmd.bat</li>
|
||||
<li>Bruce Kelly - bug report 1376756 for UselessOverridingMethod, bug report 1376760 for InefficientStringBuffering</li>
|
||||
<li>Allan Caplan - wrote AppendCharacterWithChar, wrote IntegerInstantiation, wrote UseStringBufferLength, wrote AvoidEnumAsIdentifier, bug report 1313216 for designer flaw, patch 1306999 to enhance CloseResource to check for more types, suggested including suppressed rule violations in the report</li>
|
||||
<li>Wouter Zelle - Renderer improvement suggestions, wrote NonThreadSafeSingleton rule, wrote DefaultPackage rule, worked thru ASTMethodDeclaration.isSyntacticallyX design, reported docs bug 1292689 for UnnecessaryLocalBeforeReturn, reported leftover ExceptionTypeChecking source file, rewrote UselessOverridingMethod in Java, UselessOverridingMethod rule, ProperLogger rule, nifty code to allow variables in XPath rules, externalInfoUrl data for all rules in basic and unusedcode rulesets, some very nifty XSLT, improvements to UseCorrectExceptionLogging, designed and implemented the "externalInfoUrl" feature in the rule definitions, fixed a devious bug in RuleSetFactory, AvoidPrintStackTrace, initial implementation of SimplifyConditional</li>
|
||||
<li>Bhatia Saurabh - reported a bug in UseStringBufferLength</li>
|
||||
|
Reference in New Issue
Block a user