@Override
public MethodVisitor visitMethod(final int access, final String name, final String desc, final String signature,
final String[] exceptions) {
if (Character.isUpperCase(name.charAt(0))) {
BugInstance bug0 = new BugInstance(this, "NM_METHOD_NAMING_CONVENTION", NORMAL_PRIORITY).addClass(this).addMethod(
this.name, name, desc, access);
bugReporter.reportBug(bug0);
}
return new AbstractFBMethodVisitor() {
int prevOpcode;
int prevPC;
@Override
public void visitInsn(int opcode) {
prevOpcode = opcode;
prevPC = getPC();
}
@Override
public void visitMethodInsn(int opcode, String owner, String invokedName, String invokedDesc, boolean itf) {
if (prevPC + 1 == getPC() && prevOpcode == I2D && opcode == INVOKESTATIC && owner.equals("java/lang/Math")
&& invokedName.equals("ceil") && invokedDesc.equals("(D)D")) {
BugInstance bug0 = new BugInstance(TestASM.this, "ICAST_INT_CAST_TO_DOUBLE_PASSED_TO_CEIL", NORMAL_PRIORITY);
MethodAnnotation methodAnnotation = MethodAnnotation.fromForeignMethod(TestASM.this.name, name, desc, access);
bug0.addClass(TestASM.this).addMethod(methodAnnotation);
bugReporter.reportBug(bug0);
}
}
};