Class: RuboCop::Cop::Rails::HttpStatus::NumericStyleChecker
- Inherits:
-
Object
- Object
- RuboCop::Cop::Rails::HttpStatus::NumericStyleChecker
- 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 `numeric` over `symbolic` to define HTTP status code.'
- PERMITTED_STATUS =
%i[error success missing redirect].freeze
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
-
#initialize(node) ⇒ NumericStyleChecker
constructor
A new instance of NumericStyleChecker.
- #message ⇒ Object
- #offensive? ⇒ Boolean
- #preferred_style ⇒ Object
Constructor Details
#initialize(node) ⇒ NumericStyleChecker
Returns a new instance of NumericStyleChecker.
132 133 134 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 132 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
130 131 132 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 130 def node @node end |
Instance Method Details
#message ⇒ Object
140 141 142 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 140 def format(MSG, prefer: preferred_style, current: symbol.inspect) end |
#offensive? ⇒ Boolean
136 137 138 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 136 def offensive? !node.int_type? && !permitted_symbol? && number end |
#preferred_style ⇒ Object
144 145 146 |
# File 'lib/rubocop/cop/rails/http_status.rb', line 144 def preferred_style number.to_s end |