Class: EagerEye::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/eager_eye/configuration.rb

Constant Summary collapse

DEFAULT_DETECTORS =
%i[
  loop_association serializer_nesting missing_counter_cache
  custom_method_query count_in_iteration callback_query
  pluck_to_array
].freeze
DEFAULT_SEVERITY_LEVELS =
{
  loop_association: :error,
  serializer_nesting: :warning,
  missing_counter_cache: :info,
  custom_method_query: :warning,
  count_in_iteration: :warning,
  callback_query: :warning,
  pluck_to_array: :warning
}.freeze
VALID_SEVERITIES =
%i[info warning error].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



26
27
28
29
30
31
32
33
# File 'lib/eager_eye/configuration.rb', line 26

def initialize
  @excluded_paths = []
  @enabled_detectors = DEFAULT_DETECTORS.dup
  @app_path = "app"
  @fail_on_issues = true
  @severity_levels = DEFAULT_SEVERITY_LEVELS.dup
  @min_severity = :info
end

Instance Attribute Details

#app_pathObject

Returns the value of attribute app_path.



5
6
7
# File 'lib/eager_eye/configuration.rb', line 5

def app_path
  @app_path
end

#enabled_detectorsObject

Returns the value of attribute enabled_detectors.



5
6
7
# File 'lib/eager_eye/configuration.rb', line 5

def enabled_detectors
  @enabled_detectors
end

#excluded_pathsObject

Returns the value of attribute excluded_paths.



5
6
7
# File 'lib/eager_eye/configuration.rb', line 5

def excluded_paths
  @excluded_paths
end

#fail_on_issuesObject

Returns the value of attribute fail_on_issues.



5
6
7
# File 'lib/eager_eye/configuration.rb', line 5

def fail_on_issues
  @fail_on_issues
end

#min_severityObject

Returns the value of attribute min_severity.



5
6
7
# File 'lib/eager_eye/configuration.rb', line 5

def min_severity
  @min_severity
end

#severity_levelsObject

Returns the value of attribute severity_levels.



5
6
7
# File 'lib/eager_eye/configuration.rb', line 5

def severity_levels
  @severity_levels
end

Instance Method Details

#severity_for(detector_name) ⇒ Object



35
36
37
# File 'lib/eager_eye/configuration.rb', line 35

def severity_for(detector_name)
  severity_levels.fetch(detector_name.to_sym, :warning)
end

#valid_severity?(severity) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/eager_eye/configuration.rb', line 39

def valid_severity?(severity)
  VALID_SEVERITIES.include?(severity.to_sym)
end