Skip to content

[DEV] Address Edge Case in MIM Refactorer #373

@Sevhena

Description

@Sevhena

The current MIM refactorer only checks for a matching method and immediately changes the instance calling it.

Need to change this so that:

  1. Checks the type of instance first to ensure that it is from appropriate class
  2. Considers subclasses

Consider the following situation:

class Test1:
  ...
  
  def mim_method(self):
    print("Hello World")

class Test2(Test1):
  ...
  pass

class Test3:
  ...

  def mim_method(self):
    print("Bye World")

test1 = Test1()
test1.mim_method()

test2 = Test2()
test2.mim_method()

test3 = Test1()
test3.mim_method()

2 smells would be generated from this script the one for Test1 and Test3. Currently, when refactoring 1 of those smells say for Test1, all calls of mim_method() would be refactored which is wrong since Test3 is a completely separate class.

The wanted behaviour is therefore for the first 2 calls to mim_method() to be refactored and the last one ignored since it isn't of the same class as the identified smell nor a subclass.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdevRelated to the Initial Development

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions