Class: RuboCop::Rails::Plugin

Inherits:
LintRoller::Plugin
  • Object
show all
Defined in:
lib/rubocop/rails/plugin.rb

Overview

A plugin that integrates RuboCop Rails with RuboCop’s plugin system.

Instance Method Summary collapse

Instance Method Details

#aboutObject



9
10
11
12
13
14
15
16
# File 'lib/rubocop/rails/plugin.rb', line 9

def about
  LintRoller::About.new(
    name: 'rubocop-rails',
    version: Version::STRING,
    homepage: 'https://github.com/rubocop/rubocop-rails',
    description: 'A RuboCop extension focused on enforcing Rails best practices and coding conventions.'
  )
end

#rules(_context) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rubocop/rails/plugin.rb', line 22

def rules(_context)
  project_root = Pathname.new(__dir__).join('../../..')

  ConfigObsoletion.files << project_root.join('config', 'obsoletion.yml')

  # FIXME: This is a dirty hack relying on a private constant to prevent
  # "Warning: AllCops does not support TargetRailsVersion parameter".
  # It should be updated to a better design in the future.
  without_warnings do
    ConfigValidator.const_set(:COMMON_PARAMS, ConfigValidator::COMMON_PARAMS.dup << 'TargetRailsVersion')
  end

  LintRoller::Rules.new(type: :path, config_format: :rubocop, value: project_root.join('config', 'default.yml'))
end

#supported?(context) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/rubocop/rails/plugin.rb', line 18

def supported?(context)
  context.engine == :rubocop
end