Class: RuboCop::Cop::Rails::HttpStatus::SymbolicStyleChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/rubocop/cop/rails/http_status.rb

Overview

:nodoc:

Constant Summary collapse

MSG =
'Prefer `%<prefer>s` over `%<current>s` to define HTTP status code.'
DEFAULT_MSG =
'Prefer `symbolic` over `numeric` to define HTTP status code.'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ SymbolicStyleChecker

Returns a new instance of SymbolicStyleChecker.



92
93
94
# File 'lib/rubocop/cop/rails/http_status.rb', line 92

def initialize(node)
  @node = node
end

Instance Attribute Details

#nodeObject (readonly)

Returns the value of attribute node.



90
91
92
# File 'lib/rubocop/cop/rails/http_status.rb', line 90

def node
  @node
end

Instance Method Details

#messageObject



100
101
102
# File 'lib/rubocop/cop/rails/http_status.rb', line 100

def message
  format(MSG, prefer: preferred_style, current: number.to_s)
end

#offensive?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/rubocop/cop/rails/http_status.rb', line 96

def offensive?
  !node.sym_type? && !custom_http_status_code?
end

#preferred_styleObject



104
105
106
# File 'lib/rubocop/cop/rails/http_status.rb', line 104

def preferred_style
  symbol.inspect
end