Class: Standard::Plugin::MergesPluginsIntoRubocopConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/standard/plugin/merges_plugins_into_rubocop_config.rb

Constant Summary collapse

MANDATORY_RUBOCOP_CONFIG_KEYS =

Blank configuration object to merge plugins into, with only the following spared:

- AllCops keys set to avoid warnings about unknown properties
- Lint/Syntax must be set to avoid a nil error when verifying inherited configs
["AllCops", "Lint/Syntax"].freeze
DISALLOWED_ALLCOPS_KEYS =

AllCops keys that standard does not allow to be set by plugins

[
  "Include",
  "Exclude",
  "StyleGuideBaseURL",
  "StyleGuideCopsOnly",
  "TargetRubyVersion",
  "EnabledByDefault",
  "DisabledByDefault",

  # The AllCops[Enabled] key is an unused artifact of #merge_with_default.
  # See: https://github.com/rubocop/rubocop/blob/master/lib/rubocop/config_loader_resolver.rb#L81-L85
  "Enabled"
].freeze

Instance Method Summary collapse

Constructor Details

#initializeMergesPluginsIntoRubocopConfig

Returns a new instance of MergesPluginsIntoRubocopConfig.



24
25
26
# File 'lib/standard/plugin/merges_plugins_into_rubocop_config.rb', line 24

def initialize
  @creates_runner_context = Standard::Plugin::CreatesRunnerContext.new
end

Instance Method Details

#call(options_config, standard_config, plugins, permit_merging:) ⇒ Object



28
29
30
31
32
33
# File 'lib/standard/plugin/merges_plugins_into_rubocop_config.rb', line 28

def call(options_config, standard_config, plugins, permit_merging:)
  runner_context = @creates_runner_context.call(standard_config)
  plugin_config = combine_rubocop_configs(options_config, runner_context, plugins, permit_merging: permit_merging).to_h
  merge_config_into_all_cops!(options_config, plugin_config)
  merge_config_into_standard!(options_config, plugin_config, permit_merging: permit_merging)
end