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
, but in fact, the method on line 101
of the downstream code is a new method and not a transformation of the attribute on line 61
of the upstream code into a parameter of this method. How can this issue be resolved?
This is the upstream URL: https://android.googlesource.com/platform/frameworks/base/+/refs/tags/android-9.0.0_r61/media/tests/MtpTests/src/android/mtp/MtpStorageManagerTest.java
This is the downstream refactored URL: https://github.com/LineageOS/android_frameworks_base/blob/lineage-16.0/media/tests/MtpTests/src/android/mtp/MtpStorageManagerTest.java
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.