Class: LintFu::Plugins::Rails::BuggyEagerLoadChecker

Inherits:
Checker
  • Object
show all
Defined in:
lib/lint_fu/plugins/rails/buggy_eager_load_checker.rb

Overview

Visit a Rails controller looking for troublesome stuff

Constant Summary collapse

FINDER_REGEXP =
/^(find|first|all)(_or_initialize)?(_by_.*)?/

Constants inherited from Checker

Checker::SUPPRESSION_COMMENT

Instance Attribute Summary

Attributes inherited from Checker

#context, #file, #scan

Instance Method Summary collapse

Methods inherited from Checker

#initialize, #method_missing, #observe_class_begin, #observe_class_end

Constructor Details

This class inherits a constructor from LintFu::Checker

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class LintFu::Checker

Instance Method Details

#observe_call(sexp) ⇒ Object

sexp

s(:call, <target>, <method_name>, s(:arglist))



46
47
48
49
50
51
52
# File 'lib/lint_fu/plugins/rails/buggy_eager_load_checker.rb', line 46

def observe_call(sexp)
  super(sexp)
  return unless finder?(sexp)
  if finder?(sexp) && (si = spotty_includes(sexp[3])) && !suppressed?(UnsafeFind)
    scan.issues << BuggyEagerLoad.new(scan, self.file, sexp, si.modeled_class_name)
  end
end