Module: Rubocop::Stylecheck::Cli
- Defined in:
- lib/rubocop/stylecheck/cli.rb
Class Method Summary collapse
- .direct_run(options) ⇒ Object
- .options ⇒ Object
- .options_with_auto_correct ⇒ Object
- .options_with_cop ⇒ Object
- .run(options) ⇒ Object
- .run_via_sh(options) ⇒ Object
Class Method Details
.direct_run(options) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rubocop/stylecheck/cli.rb', line 13 def direct_run() require "rubocop" require "benchmark" cli = RuboCop::CLI.new result = 0 time = Benchmark.realtime do result = cli.run() end puts "Finished in #{time} seconds" if cli.[:debug] exit result end |
.options ⇒ Object
34 35 36 37 38 |
# File 'lib/rubocop/stylecheck/cli.rb', line 34 def = ["--fail-level", "refactor"] += ["--rails"] if defined?(Rails) end |
.options_with_auto_correct ⇒ Object
40 41 42 |
# File 'lib/rubocop/stylecheck/cli.rb', line 40 def + ["--auto-correct"] end |
.options_with_cop ⇒ Object
44 45 46 |
# File 'lib/rubocop/stylecheck/cli.rb', line 44 def + ["--display-cop-names"] end |
.run(options) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/rubocop/stylecheck/cli.rb', line 5 def run() if Rubocop::Stylecheck.direct direct_run() else run_via_sh() end end |
.run_via_sh(options) ⇒ Object
28 29 30 31 32 |
# File 'lib/rubocop/stylecheck/cli.rb', line 28 def run_via_sh() system "bundle exec rubocop #{options.join(' ')}" do |ok, _res| abort "Fix code style errors" unless ok end end |