tsantalis/RefactoringMiner

Wrong Parameterize Attribute

l123zy opened this issue · 3 comments

I am using a tool to perform refactoring detection between two code repositories. The detected result shows that a 'Parameterize Attribute' type refactoring has occurred
3
, but in fact, the method on line 101
2
of the downstream code is a new method and not a transformation of the attribute on line 61
1
of the upstream code into a parameter of this method. How can this issue be resolved?

@l123zy
Could you please provide the commit URL for this case?

Hello @l123zy
I examined the AST diff generated by our tool.
There is a newly extracted method private createNewFileNonZero(parent File, name String), which is extracted from multiple tests.

private static File createNewFileNonZero(File parent) {
        return createNewFileNonZero(parent, "file-" + UUID.randomUUID().toString());
}

private static File createNewFileNonZero(File parent, String name) {
        return createNewFile(parent, name, true);
}

In all call sites, we have the following change:
File newFile = createNewFile(mainStorageDir); ->
File newFile = createNewFileNonZero(mainStorageDir);

The reported refactoring is simply saying that in the extracted method createNewFileNonZero
the attribute mainStorageDir has become the parameter parent.

This actually is correct, instead of using directly the attribute mainStorageDir the extracted method createNewFileNonZero introduced the parameter parent in order to make the method more reusable.

As you can see there are also some calls to the extracted method passing other arguments, such as moved
createNewFileNonZero(moved);
This strengthens the argument that the parameter parent was introduced for reusability.

Please let me know if you have a different opinion.