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
find_each find_in_batches in_batches array!].freeze
AR_BATCH_METHODS =
%i[find_each find_in_batches in_batches].freeze
NON_AR_NAMESPACES =
%w[Sidekiq Redis ActionCable ActionMailer Kafka].freeze
TRANSACTIONAL_CALLBACKS =
%i[before_validation before_save before_create before_update before_destroy
around_save around_create around_update around_destroy].freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

default_severity

Class Method Details

.detector_nameObject



36
37
38
# File 'lib/eager_eye/detectors/callback_query.rb', line 36

def self.detector_name
  :callback_query
end

Instance Method Details

#detect(ast, file_path) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/eager_eye/detectors/callback_query.rb', line 40

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