I'm getting below error in my Robot class:
Commands tests @robot.placed at least 4 times (RepeatedConditional)
This is the problematic code that's causing it:
def move
@robot.move_forward if @robot.placed
end
def left
@robot.left if @robot.placed
end
def right
@robot.right if @robot.placed
end
def report
puts @robot.report_current_position if @robot.placed
end
How would we re-organise this to avoid this warning?
you should refactor it out in a single method
and then call the method in your methods
And put robot_placed? in the private section of your class ;-)