Module: Bullet::StackTraceFilter

Included in:
Detector::NPlusOneQuery, Detector::UnusedEagerLoading
Defined in:
lib/bullet/stack_trace_filter.rb

Constant Summary collapse

VENDOR_PATH =
'/vendor'
IS_RUBY_19 =
Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')

Instance Method Summary collapse

Instance Method Details

#caller_in_project(bullet_key = nil) ⇒ Object

Parameters:

  • bullet_key (String) (defaults to: nil)
    • use this to get stored call stack from call_stacks object.



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

def caller_in_project(bullet_key = nil)
  vendor_root = Bullet.app_root + VENDOR_PATH
  bundler_path = Bundler.bundle_path.to_s
  select_caller_locations(bullet_key) do |location|
    caller_path = location_as_path(location)
    caller_path.include?(Bullet.app_root) && !caller_path.include?(vendor_root) &&
      !caller_path.include?(bundler_path) || Bullet.stacktrace_includes.any? { |include_pattern|
                                               pattern_matches?(location, include_pattern)
                                             }
  end
end

#excluded_stacktrace_path?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
# File 'lib/bullet/stack_trace_filter.rb', line 25

def excluded_stacktrace_path?
  Bullet.stacktrace_excludes.any? do |exclude_pattern|
    caller_in_project.any? { |location| pattern_matches?(location, exclude_pattern) }
  end
end