Class: LinterChanges::CLI

Inherits:
Thor
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/linter_changes/cli.rb

Constant Summary collapse

AVAILABLE_LINTERS =
{
  'rubocop' => LinterChanges::Linter::RuboCop::Adapter,
  'eslint' => LinterChanges::Linter::Eslint::Adapter
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'lib/linter_changes/cli.rb', line 44

def self.exit_on_failure?
  true
end

Instance Method Details

#lintObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/linter_changes/cli.rb', line 28

def lint
  Logger.debug_mode = options[:debug]

  Logger.debug "Using configuration file: #{options[:config_file]}"
  @config = LinterChanges::Config.load(config_file: options[:config_file])
  overall_success = T.let(true, T::Boolean)

  select_linters.each do |linter|
    Logger.debug "Running #{linter.name.capitalize} linter"
    overall_success &&= linter.run
  end

  exit(overall_success ? 0 : 1)
end