Reputation: 10412
I have below error:
tests @action.placed.!=(true) at least 3 times (RepeatedConditional)
Generated from below code:
def left
super unless @action.placed != true
end
def right
super unless @action.placed != true
end
def move_forward
super unless @action.placed != true
end
How would we get rid of this repeat?
Upvotes: 2
Views: 550
Reputation: 152
I think this explains it best: https://github.com/troessner/reek/blob/master/lib/reek/report/code_climate/code_climate_configuration.yml#L619. Because your object is checking the same condition multiple times, it is probably assuming the role of 2 objects and is missing an abstraction.
The solution may be creating 2 classes, one where @action.placed
is always true and one where it is not always true. Another could be moving the logic up. Or maybe just combining these methods into 1. Ideally the goal would be to only have to check that condition once.
Upvotes: 0
Reputation: 5895
Will an alias work?
alias :right :left
alias :move_forward :left
Upvotes: 0