Class: RuboCop::Git::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/git/runner.rb

Overview

Instance Method Summary collapse

Constructor Details

#initialize(exit_on_offence: true) ⇒ Runner

Returns a new instance of Runner.



7
8
9
# File 'lib/rubocop/git/runner.rb', line 7

def initialize(exit_on_offence: true)
  @exit_on_offence = exit_on_offence
end

Instance Method Details

#run(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rubocop/git/runner.rb', line 11

def run(options = {})
  options = Options.new(options) unless options.is_a?(Options)

  @options = options
  @files = DiffParser.parse(git_diff(options))

  display_violations($stdout)

  ok = violations_with_valid_offences.none?
  exit(1) if @exit_on_offence && !ok
  ok
end