Module: RuboCop::Cop::Style::RbsInline::ModeConfig

Included in:
FileFilter, RequireRbsInlineComment
Defined in:
lib/rubocop/cop/style/rbs_inline/mixin/mode_config.rb,
sig/rubocop/cop/style/rbs_inline/mixin/mode_config.rbs

Overview

Resolves the Mode setting shared by every cop in the Style/RbsInline department.

Constant Summary collapse

SUPPORTED_MODES =

RBS:

  • type mode = :opt_in | :opt_out

Returns:

  • (Array[mode])
%i[opt_in opt_out].freeze

Instance Method Summary collapse

Instance Method Details

#configured_modemode

Signature:

  • mode

Returns:

  • (mode)

Raises:



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rubocop/cop/style/rbs_inline/mixin/mode_config.rb', line 24

def configured_mode #: mode
  raw = cop_config["Mode"]
  # `raw.to_s.to_sym` handles YAML-native Integer / Boolean without
  # raising NoMethodError on the plain `to_sym`.
  mode = raw.to_s.to_sym
  return mode if SUPPORTED_MODES.include?(mode)

  raise ValidationError,
        "`Style/RbsInline: Mode: #{raw.inspect}` is not supported. " \
        "Expected one of: #{SUPPORTED_MODES.join(", ")}."
end

#validate_configvoid

This method returns an undefined value.

Hook RuboCop calls while mobilizing its cops, so an unsupported Mode fails the run as a config error instead of an error on every file.



18
19
20
# File 'lib/rubocop/cop/style/rbs_inline/mixin/mode_config.rb', line 18

def validate_config #: void
  configured_mode
end