pmd: fixed #1060 GodClassRule >>> wrong method

This commit is contained in:
Andreas Dangel 2013-01-19 18:28:33 +01:00
parent e3708b5030
commit 7989ae1863
3 changed files with 18 additions and 12 deletions

View File

@ -6,6 +6,7 @@ Fixed bug 1043: node.getEndLine() always returns 0 (ECMAscript)
Fixed bug 1044: Unknown option: -excludemarker Fixed bug 1044: Unknown option: -excludemarker
Fixed bug 1047: False Positive in 'for' loops for LocalVariableCouldBeFinal in 5.0.1 Fixed bug 1047: False Positive in 'for' loops for LocalVariableCouldBeFinal in 5.0.1
Fixed bug 1048: CommentContent Rule, String Index out of range Exception Fixed bug 1048: CommentContent Rule, String Index out of range Exception
Fixed bug 1060: GodClassRule >>> wrong method
November 28, 2012 - 5.0.1: November 28, 2012 - 5.0.1:

View File

@ -154,18 +154,20 @@ public class GodClassRule extends AbstractJavaRule {
int pairs = 0; int pairs = 0;
if (methodCount > 1) { if (methodCount > 1) {
for (int i = 0; i < methodCount - 1; i++) { for (int i = 0; i < methodCount; i++) {
String firstMethodName = methods.get(i); for (int j = i + 1; j < methodCount; j++) {
String secondMethodName = methods.get(i + 1); String firstMethodName = methods.get(i);
Set<String> accessesOfFirstMethod = methodAttributeAccess.get(firstMethodName); String secondMethodName = methods.get(j);
Set<String> accessesOfSecondMethod = methodAttributeAccess.get(secondMethodName); Set<String> accessesOfFirstMethod = methodAttributeAccess.get(firstMethodName);
Set<String> combinedAccesses = new HashSet<String>(); Set<String> accessesOfSecondMethod = methodAttributeAccess.get(secondMethodName);
Set<String> combinedAccesses = new HashSet<String>();
combinedAccesses.addAll(accessesOfFirstMethod);
combinedAccesses.addAll(accessesOfSecondMethod); combinedAccesses.addAll(accessesOfFirstMethod);
combinedAccesses.addAll(accessesOfSecondMethod);
if (combinedAccesses.size() < (accessesOfFirstMethod.size() + accessesOfSecondMethod.size())) {
pairs++; if (combinedAccesses.size() < (accessesOfFirstMethod.size() + accessesOfSecondMethod.size())) {
pairs++;
}
} }
} }
} }

View File

@ -1,3 +1,6 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.lang.java.rule.design; package net.sourceforge.pmd.lang.java.rule.design;
import net.sourceforge.pmd.testframework.SimpleAggregatorTst; import net.sourceforge.pmd.testframework.SimpleAggregatorTst;