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

#aboutLintRoller::About

RuboCop::SortedMethodsByCall::Plugin#about -> LintRoller::About

Declares plugin metadata (name, version, homepage, description).

Returns:

  • (LintRoller::About)

    Metadata describing this plugin.



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

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) ⇒ LintRoller::Rules

RuboCop::SortedMethodsByCall::Plugin#rules -> LintRoller::Rules

Returns the plugin rules for RuboCop. This points RuboCop to the default configuration file shipped with the gem (config/default.yml).

Parameters:

  • _context (Object)

    LintRoller context (unused).

Returns:

  • (LintRoller::Rules)

    Rule declaration for RuboCop to load.

See Also:

  • RuboCop::SortedMethodsByCall::Plugin.config/defaultconfig/default.yml


52
53
54
55
56
57
58
# File 'lib/rubocop/sorted_methods_by_call/plugin.rb', line 52

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

#supported?(context) ⇒ Boolean

RuboCop::SortedMethodsByCall::Plugin#supported? -> Boolean

Indicates that this plugin supports RuboCop as the lint engine.

Parameters:

  • context (Object)

    LintRoller context (engine, versions, etc.).

Returns:

  • (Boolean)

    true for RuboCop engine; false otherwise.



39
40
41
# File 'lib/rubocop/sorted_methods_by_call/plugin.rb', line 39

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