Class: RubocopChallenger::Rubocop::Command

Inherits:
Object
  • Object
show all
Includes:
PrComet::CommandLine
Defined in:
lib/rubocop_challenger/rubocop/command.rb

Overview

To execute rubocop gem command (Mainly for mock when testing)

Instance Method Summary collapse

Instance Method Details

#auto_gen_config(exclude_limit: nil, auto_gen_timestamp: true, offense_counts: true, only_exclude: false) ⇒ Object

Generates ‘.rubocop_todo.yml`

Parameters:

  • exclude_limit (Integer) (defaults to: nil)

    default: nil

  • auto_gen_timestamp (Boolean) (defaults to: true)

    default: true

  • offense_counts (Boolean) (defaults to: true)

    default: true

  • only_exclude (Boolean) (defaults to: false)

    default: false



24
25
26
27
28
29
30
31
# File 'lib/rubocop_challenger/rubocop/command.rb', line 24

def auto_gen_config(exclude_limit: nil, auto_gen_timestamp: true, offense_counts: true, only_exclude: false)
  commands = ['--auto-gen-config']
  commands << "--exclude-limit #{exclude_limit}" if exclude_limit
  commands << '--no-auto-gen-timestamp' unless auto_gen_timestamp
  commands << '--no-offense-counts' unless offense_counts
  commands << '--auto-gen-only-exclude' if only_exclude
  run(*commands)
end

#autocorrect(only_safe_autocorrect:) ⇒ Object

Executes auto correction



10
11
12
13
14
15
16
# File 'lib/rubocop_challenger/rubocop/command.rb', line 10

def autocorrect(only_safe_autocorrect:)
  if only_safe_autocorrect
    run('-a') # --autocorrect     Autocorrect offenses (only when it's safe).
  else
    run('-A') # --autocorrect-all Autocorrect offenses (safe and unsafe).
  end
end