I'm getting below errors from reek
:
lib/actions.rb -- 5 warnings:
Actions#move_forward calls (self.x_coordinate + unit) twice (DuplicateMethodCall)
Actions#move_forward calls place((self.x_coordinate + unit), self.y_coordinate, self.direction) twice (DuplicateMethodCall)
Actions#move_forward calls self.direction 5 times (DuplicateMethodCall)
Actions#move_forward calls self.x_coordinate 4 times (DuplicateMethodCall)
Actions#move_forward calls self.y_coordinate 4 times (DuplicateMethodCall)
Below is the method move_forward
def move_forward(unit = 1)
case self.direction
when Direction::SOUTH
place(self.x_coordinate, self.y_coordinate - unit, self.direction)
when Direction::EAST
place(self.x_coordinate + unit, self.y_coordinate, self.direction)
when Direction::NORTH
place(self.x_coordinate, self.y_coordinate + unit, self.direction)
when Direction::WEST
place(self.x_coordinate - unit, self.y_coordinate, self.direction)
else
end
end
I want to remove all errors especially duplicate method call. What would be the best way to fix all warnings in this case?
Maybe something like this?
I find the complaints about the "duplicate calls" to
self.x_coordindate
andself.y_coordinate
kinda false-positivey though, they're only called once per path.