Class: EagerEye::Detectors::ScopeChainNPlusOne

Inherits:
Base
  • Object
show all
Defined in:
lib/eager_eye/detectors/scope_chain_n_plus_one.rb

Constant Summary collapse

ITERATION_METHODS =
%i[each map select find_all reject collect detect find_index flat_map
find_each find_in_batches in_batches array!].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

default_severity

Class Method Details

.detector_nameObject



9
10
11
# File 'lib/eager_eye/detectors/scope_chain_n_plus_one.rb', line 9

def self.detector_name
  :scope_chain_n_plus_one
end

Instance Method Details

#detect(ast, file_path, scope_maps = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/eager_eye/detectors/scope_chain_n_plus_one.rb', line 13

def detect(ast, file_path, scope_maps = {})
  return [] unless ast

  @issues = []
  @file_path = file_path
  @all_scopes = scope_maps.each_value.reduce(Set.new, :merge)
  return [] if @all_scopes.empty?

  find_iteration_blocks(ast)
  @issues
end