ml-in-programming / ArchitectureReloaded

Design defects detection plugin for IntelliJ IDEA. Based on BasLeijdekkers/MetricsReloaded plugin.
Other
8 stars 3 forks source link

CCDA produces strange refactorings #162

Open Ivan-Veselov opened 6 years ago

Ivan-Veselov commented 6 years ago
package com.example;

public class B {
    private int field1;

    private int field2;

    private int field3;

    public int getField1() {
        return field1;
    }

    public int getField2() {
        return field2;
    }

    public int getField3() {
        return field3;
    }
}
package com.example;

public class A {
    void method1() {
        B b = new B();

        b.getField1();
        b.getField2();
    }

    void method2() {
        B b = new B();

        b.getField1();
        b.getField3();
    }

    void method3() {
        B b = new B();

        b.getField2();
        b.getField3();
    }
}

CCDA output:

com.example.A.method3() -> com.example.B [0.83]
com.example.B.getField1() -> com.example.A [0.60]

Problem 1: From logical point of view the first suggestion is correct. But where are the two others which are symmetrical? Problem 2: The second refactoring is very strange. It suggests to move getter. And such suggestions arise very often. For example there are many of them in spellchecker module of community IDEA project.

Ivan-Veselov commented 6 years ago

Possible reason for problem 1 is that CCDA logically applies each found refactoring and continues its execution. Am I right?