Class: AndOne::IgnoreFile
- Inherits:
-
Object
- Object
- AndOne::IgnoreFile
- Defined in:
- lib/and_one/ignore_file.rb
Overview
Parses and matches against a .and_one_ignore file.
The file supports four types of rules:
# Lines starting with # are comments
# Ignore N+1s originating from a specific gem
gem:devise
gem:administrate
# Ignore N+1s whose call stack matches a path pattern (supports * globs)
path:app/views/admin/*
path:lib/legacy/**
# Ignore N+1s matching a SQL pattern
query:schema_migrations
query:pg_catalog
# Ignore a specific detection by its fingerprint (shown in output)
fingerprint:abc123def456
Defined Under Namespace
Classes: Rule
Instance Attribute Summary collapse
-
#rules ⇒ Object
readonly
Returns the value of attribute rules.
Instance Method Summary collapse
-
#ignored?(detection, raw_caller_strings) ⇒ Boolean
Check if a detection should be ignored.
-
#initialize(path = nil) ⇒ IgnoreFile
constructor
A new instance of IgnoreFile.
Constructor Details
#initialize(path = nil) ⇒ IgnoreFile
Returns a new instance of IgnoreFile.
30 31 32 33 34 |
# File 'lib/and_one/ignore_file.rb', line 30 def initialize(path = nil) @path = path @rules = [] parse if @path && File.exist?(@path) end |
Instance Attribute Details
#rules ⇒ Object (readonly)
Returns the value of attribute rules.
28 29 30 |
# File 'lib/and_one/ignore_file.rb', line 28 def rules @rules end |
Instance Method Details
#ignored?(detection, raw_caller_strings) ⇒ Boolean
Check if a detection should be ignored. raw_caller_strings: the UN-cleaned caller locations (full paths, including gems) detection: the Detection object
39 40 41 42 43 |
# File 'lib/and_one/ignore_file.rb', line 39 def ignored?(detection, raw_caller_strings) return false if @rules.empty? @rules.any? { |rule| matches?(rule, detection, raw_caller_strings) } end |