123456789_123456789_123456789_123456789_123456789_

Class: RuboCop::Cop::Severity

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Comparable
Inherits: Object
Defined in: lib/rubocop/cop/severity.rb

Overview

Severity class is simple value object about severity

Constant Summary

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Class Method Details

.name_from_code(code)

[ GitHub ]

  
# File 'lib/rubocop/cop/severity.rb', line 24

def self.name_from_code(code)
  name = code.to_sym
  CODE_TABLE[name] || name
end

Instance Attribute Details

#nameSymbol (readonly)

Returns:

  • (Symbol)

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

[ GitHub ]

  
# File 'lib/rubocop/cop/severity.rb', line 22

attr_reader :name

Instance Method Details

#<=>(other)

[ GitHub ]

  
# File 'lib/rubocop/cop/severity.rb', line 62

def <=>(other)
  level <=> other.level
end

#==(other)

[ GitHub ]

  
# File 'lib/rubocop/cop/severity.rb', line 50

def ==(other)
  @name == if other.is_a?(Symbol)
             other
           else
             other.name
           end
end

#code

[ GitHub ]

  
# File 'lib/rubocop/cop/severity.rb', line 42

def code
  @name.to_s[0].upcase
end

#hash

[ GitHub ]

  
# File 'lib/rubocop/cop/severity.rb', line 58

def hash
  @name.hash
end

#level

[ GitHub ]

  
# File 'lib/rubocop/cop/severity.rb', line 46

def level
  NAMES.index(name) + 1
end

#to_s

[ GitHub ]

  
# File 'lib/rubocop/cop/severity.rb', line 38

def to_s
  @name.to_s
end