Class: RuboCop::CLI::Command::InitDotfile
- Defined in:
- lib/rubocop/cli/command/init_dotfile.rb
Overview
Generate a .rubocop.yml file in the current directory.
Constant Summary collapse
- DOTFILE =
ConfigLoader::DOTFILE
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
by_command_name, inherited, #initialize
Constructor Details
This class inherits a constructor from RuboCop::CLI::Command::Base
Instance Method Details
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubocop/cli/command/init_dotfile.rb', line 12 def run path = File.(DOTFILE) if File.exist?(DOTFILE) warn Rainbow("#{DOTFILE} already exists at #{path}").red STATUS_ERROR else description = <<~DESC # The behavior of RuboCop can be controlled via the .rubocop.yml # configuration file. It makes it possible to enable/disable # certain cops (checks) and to alter their behavior if they accept # any parameters. The file can be placed either in your home # directory or in some project directory. # # RuboCop will start looking for the configuration file in the directory # where the inspected file is and continue its way up to the root directory. # # See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md DESC File.open(DOTFILE, 'w') do |f| f.write(description) end puts "Writing new #{DOTFILE} to #{path}" STATUS_SUCCESS end end |