class RuboCop::Cop::Severity

Severity class is simple value object about severity

Constants

CODE_TABLE

@api private

NAMES

@api private

Attributes

name[R]

@api public

@!attribute [r] name

@return [Symbol]

severity.
any of `:refactor`, `:convention`, `:warning`, `:error` or `:fatal`.

Public Class Methods

name_from_code(code) click to toggle source

@api private

# File lib/rubocop/cop/severity.rb, line 26
def self.name_from_code(code)
  name = code.to_sym
  CODE_TABLE[name] || name
end
new(name_or_code) click to toggle source

@api private

# File lib/rubocop/cop/severity.rb, line 32
def initialize(name_or_code)
  name = Severity.name_from_code(name_or_code)
  unless NAMES.include?(name)
    raise ArgumentError, "Unknown severity: #{name}"
  end
  @name = name.freeze
  freeze
end

Public Instance Methods

<=>(other) click to toggle source

@api private

# File lib/rubocop/cop/severity.rb, line 71
def <=>(other)
  level <=> other.level
end
==(other) click to toggle source

@api private

# File lib/rubocop/cop/severity.rb, line 57
def ==(other)
  @name == if other.is_a?(Symbol)
             other
           else
             other.name
           end
end
code() click to toggle source

@api private

# File lib/rubocop/cop/severity.rb, line 47
def code
  @name.to_s[0].upcase
end
hash() click to toggle source

@api private

# File lib/rubocop/cop/severity.rb, line 66
def hash
  @name.hash
end
level() click to toggle source

@api private

# File lib/rubocop/cop/severity.rb, line 52
def level
  NAMES.index(name) + 1
end
to_s() click to toggle source

@api private

# File lib/rubocop/cop/severity.rb, line 42
def to_s
  @name.to_s
end