Class: RuboCop::Cop::Rails::HttpStatus::SymbolicStyleChecker
- Inherits:
-
Object
- Object
- RuboCop::Cop::Rails::HttpStatus::SymbolicStyleChecker
- 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.'.freeze
- DEFAULT_MSG =
'Prefer `symbolic` over `numeric` ' \ 'to define HTTP status code.'.freeze
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(node) ⇒ SymbolicStyleChecker
constructor
A new instance of SymbolicStyleChecker.
- #message ⇒ Object
- #offensive? ⇒ Boolean
- #preferred_style ⇒ Object
Constructor Details
#initialize(node) ⇒ SymbolicStyleChecker
Returns a new instance of SymbolicStyleChecker.
104 105 106 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 104 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
103 104 105 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 103 def node @node end |
Instance Method Details
#message ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 112 def if RACK_LOADED format(MSG, prefer: preferred_style, current: number.to_s) else DEFAULT_MSG end end |
#offensive? ⇒ Boolean
108 109 110 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 108 def offensive? !node.sym_type? && !custom_http_status_code? end |
#preferred_style ⇒ Object
120 121 122 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 120 def preferred_style symbol.inspect end |