Sha256: eb221c044ff5aa58cea8c4aacf3748c864dbc534279112b179c1f7e6f65b781b

Contents?: true

Size: 1.32 KB

Versions: 189

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module RuboCop
  class CLI
    module Command
      # Generate a .rubocop.yml file in the current directory.
      # @api private
      class InitDotfile < Base
        DOTFILE = ConfigFinder::DOTFILE

        self.command_name = :init

        def run
          path = File.expand_path(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
      end
    end
  end
end

Version data entries

189 entries across 184 versions & 19 rubygems

Version Path
rubocop-1.72.1 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.72.0 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.71.2 lib/rubocop/cli/command/init_dotfile.rb
tailscale_middleware-0.0.3 vendor/cache/ruby/3.4.0/gems/rubocop-1.71.1/lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.71.1 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.71.0 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.70.0 lib/rubocop/cli/command/init_dotfile.rb
minato_ruby_api_client-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.69.2 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.69.1 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.69.0 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.68.0 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.67.0 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.66.1 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.66.0 lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.65.1 lib/rubocop/cli/command/init_dotfile.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/rubocop-1.64.1/lib/rubocop/cli/command/init_dotfile.rb
rubocop-1.65.0 lib/rubocop/cli/command/init_dotfile.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cli/command/init_dotfile.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rubocop-1.35.1/lib/rubocop/cli/command/init_dotfile.rb