Class: RuboCop::SortedMethodsByCall::Plugin

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

Overview

RuboCop::SortedMethodsByCall::Plugin integrates this extension with RuboCop’s plugin system via lint_roller. It declares metadata and tells RuboCop where to find the plugin’s default configuration.

The plugin is discovered by RuboCop when you configure:

plugins:
  - rubocop-sorted_methods_by_call

It will automatically apply rules (config/default.yml) and make the cops available to the engine.

Instance Method Summary collapse

Instance Method Details

#aboutAbout

Return plugin metadata for lint_roller discovery.

Returns:

  • (About)


22
23
24
25
26
27
28
29
# File 'lib/rubocop/sorted_methods_by_call/plugin.rb', line 22

def about
  LintRoller::About.new(
    name: 'rubocop-sorted_methods_by_call',
    version: VERSION,
    homepage: 'https://github.com/unurgunite/rubocop-sorted_methods_by_call',
    description: 'Enforces waterfall ordering: define methods after the methods that call them.'
  )
end

#rules(_context) ⇒ Rules

Return the RuboCop rules configuration path.

Parameters:

  • _context (Object)

    The lint_roller context (unused).

Returns:

  • (Rules)


43
44
45
46
47
48
49
# File 'lib/rubocop/sorted_methods_by_call/plugin.rb', line 43

def rules(_context)
  LintRoller::Rules.new(
    type: :path,
    config_format: :rubocop,
    value: Pathname.new(__dir__ || '').realpath.join('../../../config/default.yml')
  )
end

#supported?(context) ⇒ Object

Check if the plugin is supported for the given lint_roller context.

Parameters:

  • context (Object)

    The lint_roller context to check.

Returns:

  • (Object)


35
36
37
# File 'lib/rubocop/sorted_methods_by_call/plugin.rb', line 35

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