Class: EagerEye::Detectors::CallbackQuery

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

Constant Summary collapse

CALLBACK_METHODS =
%i[
  before_validation after_validation
  before_save after_save around_save
  before_create after_create around_create
  before_update after_update around_update
  before_destroy after_destroy around_destroy
  after_commit after_rollback
  after_create_commit after_update_commit after_destroy_commit
  after_save_commit
].freeze
QUERY_INDICATORS =
%i[
  where find find_by find_by! first last take
  exists? any? none? many? one?
  count sum average minimum maximum
  pluck ids select
  update update_all update! update_attribute update_column update_columns
  destroy destroy_all destroy! delete delete_all
  create create! save save! insert insert_all insert! upsert upsert_all
  increment! decrement! toggle!
  reload
].freeze
ITERATION_METHODS =
%i[each map select find_all reject collect].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.detector_nameObject



31
32
33
# File 'lib/eager_eye/detectors/callback_query.rb', line 31

def self.detector_name
  :callback_query
end

Instance Method Details

#detect(ast, file_path) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/eager_eye/detectors/callback_query.rb', line 35

def detect(ast, file_path)
  @issues = []
  @file_path = file_path
  @callback_methods = {}

  return @issues unless ast

  find_callback_definitions(ast)
  check_callback_methods(ast)

  @issues
end