makandra / makandra-rubocop

makandra's default Rubocop configuration
MIT License
6 stars 1 forks source link

Disable Lint/Void #9

Closed foobear closed 4 years ago

foobear commented 5 years ago

Consider the following code where we want to overwrite a setter method to do something after the value has been set.

def foo=(_value)
  result = super
  # do something
  result
end

It causes Rubocop to raise Lint/Void: Variable result used in void context. for unknown reasons. The issue only affects Setters, but it is unclear to me why this is a bad thing.

A Rubocop issue was closed after not being taken care of, so it seems unlikely to be fixed soon.

I vote for just disabling this cop, as it is not that relevant.

kratob commented 5 years ago

I don't particularly mind disabling the cop, but just as a note: It usually does not matter what you return from a setter, since the expression x.foo = "bar" always evaluates to "bar", regardless what you return in the setter. I think it only matters, if you do a x.send(:"foo=", "bar") or similar.

foobear commented 5 years ago

You are right, that's probably the reasoning of the cop then. Now I'm not sure if I still want to disable it. :smile:

denzelem commented 4 years ago

I will close that issue. @foobear feel free to open it again, if you think this is indeed an issue.