Skip to content

Commit

Permalink
add fp case for PRMC
Browse files Browse the repository at this point in the history
  • Loading branch information
mebigfatguy committed Jul 21, 2018
1 parent 324ecad commit ea321eb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,14 @@ public void sawOpcode(int seen) {

if (mc != null) {
if (!signature.endsWith(Values.SIG_VOID) && methodName.equals(mc.getName()) && signature.equals(mc.getSignature())
&& !isRiskyName(className, methodName)
&& !commonMethods.contains(new FQMethod(getClassConstantOperand(), methodName, signature))) {
&& !isRiskyName(className, methodName) && !commonMethods.contains(new FQMethod(className, methodName, signature))) {
Object[] parms = mc.getParms();
if (Arrays.equals(parms, parmConstants)) {
int ln = getLineNumber(pc);

if ((ln != mc.getLineNumber()) || (Math.abs(pc - mc.getPC()) < 10)) {
Statistics statistics = Statistics.getStatistics();
MethodInfo mi = statistics.getMethodStatistics(getClassConstantOperand(), methodName, signature);
MethodInfo mi = statistics.getMethodStatistics(className, methodName, signature);

bugReporter.reportBug(
new BugInstance(this, BugType.PRMC_POSSIBLY_REDUNDANT_METHOD_CALLS.name(), getBugPriority(methodName, mi))
Expand Down
9 changes: 9 additions & 0 deletions src/samples/java/ex/PRMC_Sample.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ public void emptyList() {
List p = Collections.emptyList();
}

public void fpSimpleGetter() {
getData();
getData();
}

public String getData() {
return data;
}

enum FPEnum {
fee, fi, fo, fum
};
Expand Down

0 comments on commit ea321eb

Please sign in to comment.