Sha256: 5fa722c7bb3164353ff2b6d0f5ce30b192d2f6bec150e82157753fc6e6be83d1

Contents?: true

Size: 1.09 KB

Versions: 133

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module RuboCop
  class ConfigObsoletion
    # Base class for ConfigObsoletion rules relating to parameters
    # @api private
    class ParameterRule < Rule
      attr_reader :cop, :parameter, :metadata

      def initialize(config, cop, parameter, metadata)
        super(config)
        @cop = cop
        @parameter = parameter
        @metadata = metadata
      end

      def parameter_rule?
        true
      end

      def violated?
        applies_to_current_ruby_version? && config[cop]&.key?(parameter)
      end

      def warning?
        severity == 'warning'
      end

      private

      def applies_to_current_ruby_version?
        minimum_ruby_version = metadata['minimum_ruby_version']

        return true unless minimum_ruby_version

        config.target_ruby_version >= minimum_ruby_version
      end

      def alternative
        metadata['alternative']
      end

      def alternatives
        metadata['alternatives']
      end

      def reason
        metadata['reason']
      end

      def severity
        metadata['severity']
      end
    end
  end
end

Version data entries

133 entries across 133 versions & 12 rubygems

Version Path
harbr-0.2.7 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.2.6 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.2.5 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.2.4 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.2.3 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.2.2 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.2.1 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.2.0 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.99 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.98 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.97 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.96 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.95 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.94 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.93 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.91 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.90 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.89 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.88 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/rubocop-1.57.2/lib/rubocop/config_obsoletion/parameter_rule.rb