Class: KBuilder::Commands::RuboCopCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- KBuilder::Commands::RuboCopCommand
- Defined in:
- lib/k_builder/commands/rubo_cop_command.rb
Overview
Run RuboCop against a file
Instance Attribute Summary collapse
-
#cop_opt_values ⇒ Object
readonly
Returns the value of attribute cop_opt_values.
-
#cop_options ⇒ Object
readonly
Returns the value of attribute cop_options.
-
#file_pattern ⇒ Object
readonly
Returns the value of attribute file_pattern.
-
#fix_safe ⇒ Object
readonly
Returns the value of attribute fix_safe.
-
#fix_unsafe ⇒ Object
readonly
Returns the value of attribute fix_unsafe.
-
#rubo_config_file ⇒ Object
readonly
Returns the value of attribute rubo_config_file.
-
#show_console ⇒ Object
readonly
Returns the value of attribute show_console.
Attributes inherited from BaseCommand
Instance Method Summary collapse
- #cli_options ⇒ Object
- #debug_values ⇒ Object
- #execute ⇒ Object
-
#initialize(file_pattern, **opts) ⇒ RuboCopCommand
constructor
Initialize RuboCop command.
Methods inherited from BaseCommand
Constructor Details
#initialize(file_pattern, **opts) ⇒ RuboCopCommand
Initialize RuboCop command
32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 32 def initialize(file_pattern, **opts) super(**opts) @valid = true self.file_pattern = file_pattern self.fix_safe = opts[:fix_safe] self.fix_unsafe = opts[:fix_unsafe] self.show_console = opts[:show_console] self.rubo_config_file = opts[:rubo_config_file] end |
Instance Attribute Details
#cop_opt_values ⇒ Object (readonly)
Returns the value of attribute cop_opt_values.
14 15 16 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 14 def cop_opt_values @cop_opt_values end |
#cop_options ⇒ Object (readonly)
Returns the value of attribute cop_options.
13 14 15 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 13 def end |
#file_pattern ⇒ Object
Returns the value of attribute file_pattern.
7 8 9 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 7 def file_pattern @file_pattern end |
#fix_safe ⇒ Object
Returns the value of attribute fix_safe.
8 9 10 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 8 def fix_safe @fix_safe end |
#fix_unsafe ⇒ Object
Returns the value of attribute fix_unsafe.
9 10 11 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 9 def fix_unsafe @fix_unsafe end |
#rubo_config_file ⇒ Object
Returns the value of attribute rubo_config_file.
10 11 12 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 10 def rubo_config_file @rubo_config_file end |
#show_console ⇒ Object
Returns the value of attribute show_console.
11 12 13 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 11 def show_console @show_console end |
Instance Method Details
#cli_options ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 51 def = [] # quite is the same as simple, except you will see nothing if no offenses << '--format' << 'quiet' # 'simple' << '-a' if fix_safe << '-A' if fix_unsafe << '--config' << rubo_config_file if rubo_config_file << '--out' << File.('~/last_cop.txt') unless show_console << file_pattern end |
#debug_values ⇒ Object
63 64 65 66 67 68 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 63 def debug_values log.kv 'rubocop target', file_pattern log.kv '-a', 'automatic fix for safe issues' if fix_safe log.kv '-A', 'automatic fix for potentially unsafe issues' if fix_unsafe log.kv '-config', rubo_config_file if rubo_config_file end |
#execute ⇒ Object
45 46 47 48 49 |
# File 'lib/k_builder/commands/rubo_cop_command.rb', line 45 def execute return unless valid? cop_run end |