Class: RuboCop::CLI::Command::InitDotfile Private
- Defined in:
- lib/rubocop/cli/command/init_dotfile.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Generate a .rubocop.yml file in the current directory.
Constant Summary collapse
- DOTFILE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
ConfigFinder::DOTFILE
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #run ⇒ Object private
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
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
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 |
# File 'lib/rubocop/cli/command/init_dotfile.rb', line 13 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://docs.rubocop.org/rubocop/configuration DESC File.write(DOTFILE, description) puts "Writing new #{DOTFILE} to #{path}" STATUS_SUCCESS end end |