@@ -0,0 +1,3047 @@
+package io.disassemble.asm.visitor;%0A%0Aimport io.disassemble.asm.ClassMethodVisitor;%0Aimport org.objectweb.asm.tree.*;%0A%0Aimport static org.objectweb.asm.Opcodes.*;%0A%0Apublic class ComplexityVisitor extends ClassMethodVisitor %7B%0A%0A    private static final int%5B%5D EDGE_CASES = %7B%0A            IFEQ, IFNE, IFLT, IFGE, IFGT, IFLE, IF_ICMPEQ, IF_ICMPNE, IF_ICMPLT,%0A            IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ACMPEQ, IF_ACMPNE, IFNULL, IFNONNULL%0A    %7D;%0A%0A    private int edges = 0, nodes = 0;%0A    private int complexity = 1;%0A%0A    /**%0A     * Gets the amount of edges visited.%0A     * %0A     * @return The amount of edges visited.%0A     */%0A    public int edges() %7B%0A        return edges;%0A    %7D%0A%0A    /**%0A     * Gets the amount of nodes visited.%0A     * %0A     * @return The amount of nodes visited.%0A     */%0A    public int nodes() %7B%0A        return nodes;%0A    %7D%0A%0A    /**%0A     * Gets the mccabe cyclomatic complexity.%0A     * %0A     * @return The mccabe cyclomatic complexity.%0A     */%0A    public int mccabe() %7B%0A        return edges - nodes + 2;%0A    %7D%0A%0A    /**%0A     * Gets the standard complexity of the method visited.%0A     * %0A     * @return The standard complexity of the method visited.%0A     */%0A    public int complexity() %7B%0A        return complexity;%0A    %7D%0A%0A    private void incrementBoth() %7B%0A        edges++;%0A        nodes++;%0A    %7D%0A%0A    @Override%0A    public void visitCode() %7B%0A        super.visitCode();%0A        edges = 0;%0A        nodes = 0;%0A        complexity = 1;%0A    %7D%0A%0A    @Override%0A    public void visitFieldInsn(FieldInsnNode fin) %7B%0A        incrementBoth();%0A    %7D%0A%0A    @Override%0A    public void visitIincInsn(IincInsnNode iin) %7B%0A        incrementBoth();%0A    %7D%0A%0A    @Override%0A    public void visitInsn(InsnNode in) %7B%0A        incrementBoth();%0A    %7D%0A%0A    @Override%0A    public void visitIntInsn(IntInsnNode iin) %7B%0A        incrementBoth();%0A    %7D%0A%0A    @Override%0A    public void visitJumpInsn(JumpInsnNode jin) %7B%0A        incrementBoth();%0A        edges++;%0A        for (int edge : EDGE_CASES) %7B%0A            if (jin.getOpcode() == edge) %7B%0A                complexity++;%0A                return;%0A            %7D%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void visitLabel(LabelNode ln) %7B%0A        nodes++;%0A    %7D%0A%0A    @Override%0A    public void visitLdcInsn(LdcInsnNode lin) %7B%0A        incrementBoth();%0A    %7D%0A%0A    @Override%0A    public void visitLookupSwitchInsn(LookupSwitchInsnNode lsin) %7B%0A        nodes++;%0A        edges += lsin.labels.size();%0A        complexity += lsin.labels.size();%0A    %7D%0A%0A    @Override%0A    public void visitMethodInsn(MethodInsnNode min) %7B%0A        incrementBoth();%0A    %7D%0A%0A    @Override%0A    public void visitMultiANewArrayInsn(MultiANewArrayInsnNode manain) %7B%0A        incrementBoth();%0A    %7D%0A%0A    @Override%0A    public void visitTableSwitchInsn(TableSwitchInsnNode tsin) %7B%0A        nodes++;%0A        edges += tsin.labels.size();%0A        complexity += tsin.labels.size();%0A    %7D%0A%0A    @Override%0A    public void visitTypeInsn(TypeInsnNode tin) %7B%0A        incrementBoth();%0A    %7D%0A%0A    @Override%0A    public void visitVarInsn(VarInsnNode vin) %7B%0A        incrementBoth();%0A    %7D%0A%7D

Add ComplexityVisitor