我收到以下错误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)
下面是方法 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
我想删除所有错误,尤其是重复的方法调用。在这种情况下,解决所有警告的最佳方法是什么?