Class: LintFu::Rails::BuggyEagerLoadChecker

Inherits:
Checker
  • Object
show all
Defined in:
lib/lint_fu/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_.*)?/

Instance Attribute Summary

Attributes inherited from Checker

#context, #file, #scan

Instance Method Summary collapse

Methods inherited from Checker

#initialize

Constructor Details

This class inherits a constructor from LintFu::Checker

Instance Method Details

#observe_call(sexp) ⇒ Object

sexp

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



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

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