terryyin / lizard

A simple code complexity analyser without caring about the C/C++ header files or Java imports, supports most of the popular languages.
Other
1.85k stars 250 forks source link

Fail to recognize the java anonymous class #285

Open cyw3 opened 4 years ago

cyw3 commented 4 years ago

Lizard can not recognize the anonymous class very well, and then adds the cyclomatic complexity of all functions in the anonymous class and calculates it in the cyclomatic complexity of the function where the anonymous class is located.

I think this is inaccurate.

For example, here is a demo java:

class Demo{
    public void test() {
        new Thread(new Runnable() {

            @Override
            public void run() {
                if(true) {
                    System.out.println("Hello");
                }
            }

            public void testA() {
                if(true) {
                    System.out.println("World!");
                }
            }
        }).start();
    }
}

output is: 15,3,66,0,17,"Demo::test@4-20@/xxx/Demo.java","/xxx/Demo.java","Demo::test","Demo::test()",4,20