から以下のエラーが発生しています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
すべてのエラー、特に重複したメソッド呼び出しを削除したい。この場合、すべての警告を修正する最善の方法は何でしょうか?