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

Don't rename variables that are only referenced once #264

Open
jlukas opened this issue Oct 14, 2014 · 2 comments
Open

Don't rename variables that are only referenced once #264

jlukas opened this issue Oct 14, 2014 · 2 comments

Comments

@jlukas
Copy link

jlukas commented Oct 14, 2014

If I have the following implementation:

class MyClass
  def self.instance
    @@instance ||= new
  end
end

Mutant changes it to:

class MyClass
  def self.instance
    @@instance__mutant__ ||= new
  end
end

Which works in exactly the same way. I think mutant should not modify the name of the variable if it is not referenced anywhere else (maybe also looking for var ||= value).

@mbj
Copy link
Owner

mbj commented Oct 14, 2014

I always wanted not to mutate ivars on the lhs of an or op assgn like this. But the "Variables only refernced once" is also a nice idea to overcome this. I'll look into this idea. Thx.

@mbj
Copy link
Owner

mbj commented Oct 14, 2014

BTW: I typically dislike and avoid all ||= usages on ivars since this leads to thread safety problems. This is the reason this issue was not pressuring enough for me to get a rid of.

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

No branches or pull requests

2 participants