Module: Formatters::RuboCop
- Defined in:
- lib/arb/formatters/rubocop.rb
Class Method Summary collapse
-
.format(file_path) ⇒ Object
Formats newly created files using RuboCop if it is bundled at the top level (i.e. as ‘gem “rubocop”` in the Gemfile) or if a RuboCop config file is present.
Class Method Details
.format(file_path) ⇒ Object
Formats newly created files using RuboCop if it is bundled at the top level (i.e. as ‘gem “rubocop”` in the Gemfile) or if a RuboCop config file is present. Does nothing if RuboCop isn’t bundled or is just a dependency (e.g. of Standard), and if there is no RuboCop config file.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/arb/formatters/rubocop.rb', line 7 def self.format(file_path) require "bundler" require "rubocop" return unless rubocop_bundled_at_top_level? || rubocop_config_exists? ::RuboCop::CLI.new.run(["-A", file_path, "--out", File::NULL]) rescue LoadError # Do nothing if Bundler is not installed, or if RuboCop is bundled but not # actually installed. end |