Exception: RuboCop::Changed::CommandError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/rubocop/changed/command_error.rb

Overview

This class get changed

Constant Summary collapse

ISSUE_URL =
'https://github.com/dukaev/rubocop-changed/issues'
MESSAGES =
{
  'git: not found' =>
    'The git binary is not available in the PATH. You may need to install git or update the PATH variable to ' \
    'include the installation directory.',
  'fatal: not a git repository' =>
    'The .git directory was not found. Rubocop-changed only works with projects in a git repository.',
  'fatal: ambiguous argument' =>
    'The set branch was not found. Ensure that the branch has a local tracking branch or specify the full ' \
    'reference in the RUBOCOP_CHANGED_BRANCH_NAME environment variable.'
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(output, cmd) ⇒ CommandError

Returns a new instance of CommandError.



19
20
21
22
23
# File 'lib/rubocop/changed/command_error.rb', line 19

def initialize(output, cmd)
  key = MESSAGES.keys.find { |error| output.include?(error) }
  message = MESSAGES[key] || "Unknown error. Please, create issue on #{ISSUE_URL}."
  super(exception_message(cmd, output, message))
end

Instance Method Details

#exception_message(cmd, output, message) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/rubocop/changed/command_error.rb', line 25

def exception_message(cmd, output, message)
  "    \#{message}\n    Command:\n    \#{cmd}\n    Output:\n    \#{output}\n\n  HEREDOC\nend\n"