Class: Ducalis::FetchExpression
- Inherits:
-
RuboCop::Cop::Cop
- Object
- RuboCop::Cop::Cop
- Ducalis::FetchExpression
- Defined in:
- lib/ducalis/cops/fetch_expression.rb
Constant Summary collapse
- HASH_CALLING_REGEX =
/\:\[\]/.freeze
- OFFENSE =
<<-MESSAGE.gsub(/^ +\|\s/, '').strip | You can use `fetch` instead: | ```ruby | %<source>s | ``` | If your hash contains `nil` or `false` values and you want to treat them not like an actual values you should preliminarily remove this values from hash. | You can use `compact` (in case if you do not want to ignore `false` values) or `keep_if { |key, value| value }` (if you want to ignore all `false` and `nil` values). MESSAGE
Instance Method Summary collapse
Instance Method Details
#investigate(processed_source) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/ducalis/cops/fetch_expression.rb', line 20 def investigate(processed_source) return unless processed_source.ast matching_nodes(processed_source.ast).each do |node| add_offense(node, :expression, format(OFFENSE, source: correct_variant(node))) end end |