Как исправить «Обнаружен несоответствующий отступ» - PullRequest
0 голосов
/ 09 февраля 2020

Я пытаюсь отправить код для задания, которое у меня есть на моем курсе, и я получаю следующую ошибку:

1) Q2. Rock, paper, scissors has acceptable code quality
    Failure/Error: expect(code_quality.acceptable?).to(eq(true), code_quality.problems)

      Inspecting 1 file
      C

      Offenses:

      questions/question_2.rb:26:3: C: Layout/IndentationConsistency: Inconsistent indentation detected.
        if p1 == "scissors" && p2 == "paper" || ...
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      1 file inspected, 1 offense detected

      Diff:
      @@ -1,2 +1,2 @@
      -true
      +false
    # ./spec/question_2_spec.rb:87:in `block (2 levels) in <top (required)>'

Ниже приведен мой код вместе с описанием запроса:

puts "Player 1 input move"
p1 = gets.chomp()
puts "Player 2 input move"
p2 = gets.chomp()
  if p1 == "scissors" && p2 == "paper" ||
    p1 == "paper" && p2 == "rock" ||
    p1 == "rock" && p2 == "scissors"
    puts "Player 1 wins"
  elsif p1 == "rock" && p2 == "paper" ||
    p1 == "paper" && p2 == "scissors" ||
    p1 == "scissors" && p2 == "rock"
    puts "Player 2 wins"
  elsif p1 == "scissors" && p2 == "scissors" ||
    p1 == "paper" && p2 == "paper" ||
    p1 == "rock" && p2 == "rock"
    puts "It's a draw"
  end

**TASK DESCRIPTION
# Write a program that lets two players play Rock, Paper, Scissors. The program should:
# * Ask player 1 for their move.  They can input `rock`, `paper` or
#   `scissors`.
# * Ask player 2 for their move.  They can input `rock`, `paper` or
#   `scissors`.
# * Calculates who has won.  `rock` beats `scissors`, `paper` beats
#   `rock`, `scissors` beat `paper`.
# * If player 1 has won, `puts`es `Player 1 wins`.
# * If player 2 has won, `puts`es `Player 2 wins`.
# * If the game is a draw, `puts`es `It's a draw`.
#
# * Note: You can assume that players will input one of the three
#   possible moves described above.
#
# * Note: When you run the automated tests, the tests will simulate
#   the user input.  You shouldn't need to enter any input manually.
#   If the tests hang when you run them, it probably means your code
#   doesn't work correctly, yet.
#
# * Note: You can assume the players will only ever input `rock`,
#   `paper` or 'scissors'

Я предполагаю, что это не интервал, потому что я поменял местами после if один раз, проверил и дважды проверил пробелы, а также поиграл с общим интервалом кода.

Основная строка выдает ошибку:

if p1 == "scissors" && p2 == "paper" ||

Что я делаю не так?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...