Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is the Inline Method refactoring a true instance? #15

Open
osmarleandro opened this issue Jan 17, 2021 · 2 comments
Open

Is the Inline Method refactoring a true instance? #15

osmarleandro opened this issue Jan 17, 2021 · 2 comments

Comments

@osmarleandro
Copy link

Summary

In the source code of osmarleandro/spring-boot@0022080 commit, I applied a single Move Method refactoring to getType(Class) method in MBeanInfoFactory class, moving to JmxOperationResponseMapper interface. RefDiff yields a single Inline Method refactoring as result. Why is the Move Method refactoring instance not detected?

Code example

Diff fragment between the commit osmarleandro/spring-boot@0022080 and their parent.

@@ -38,4 +38,8 @@ public interface JmxOperationResponseMapper {
         */
        Object mapResponse(Object response);
 
+       default String getType(MBeanInfoFactory mBeanInfoFactory, Class<?> outputType) {
+               return mapResponseType(outputType).getName();
+       }
+
 }

@@ -69,7 +69,7 @@ class MBeanInfoFactory {
                String name = operation.getName();
                String description = operation.getDescription();
                MBeanParameterInfo[] signature = getSignature(operation.getParameters());
-               String type = getType(operation.getOutputType());
+               String type = responseMapper.getType(this, operation.getOutputType());
                int impact = getImpact(operation.getType());
                return new ModelMBeanOperationInfo(name, description, signature, type, impact);
        }
        
@@ -92,8 +92,4 @@ class MBeanInfoFactory {
                return MBeanOperationInfo.UNKNOWN;
        }
 
-       private String getType(Class<?> outputType) {
-               return this.responseMapper.mapResponseType(outputType).getName();
-       }
-
 }

Environment details

RefDiff 2.0

Steps to reproduce

  1. Run RefDiff and pass as input the commit osmarleandro/spring-boot@0022080.

Actual results

INLINE	{Method getType(Class) at spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/MBeanInfoFactory.java:95}	{Method getMBeanOperation(JmxOperation) at spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/MBeanInfoFactory.java:68})

Expected results

An instance of the Move Method refactoring applied to getType(Class) method in MBeanInfoFactory class and moved to JmxOperationResponseMapper interface.

@danilofes
Copy link
Collaborator

Osmar,
In this case, the MOVE was not detected because the similarity score between the method before/after is not higher than 0.5 (in fact is exactly 0.5). Unfortunately, when the method is very small, even small changes may cause this.

By the way, you may want to take a look at RefDiffExampleWithDebugger.java. It may help finding out the reason why a refactoring is not detected.

@osmarleandro
Copy link
Author

Hi @danilofes, thanks for your attention and support.

As you explained, I understand that the similarity score in small programs is not high enough. Is there any future solution to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants