Class: Pronto::RubyCritic::SmellFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/pronto/rubycritic/smell_filter.rb

Overview

Applies user-provided filters from .rubycritic-pronto.yml to the list of analysed modules. Only implements filters that map to real RubyCritic attributes. See CHANGELOG for features dropped in 0.12.0 (reek.min_severity).

Every config value is consumed defensively: a malformed section (non-Hash) or a wrong-typed value (non-numeric threshold, scalar ‘exclude`, junk `max_smells`) is ignored rather than raising. A raise here would be swallowed by the runner’s top-level rescue and silently turn the whole quality gate into a false “all clear” — the worst failure mode for a linter.

Constant Summary collapse

SMELL_FILTER_KEYS =
%w[flay flog reek].freeze

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ SmellFilter

Returns a new instance of SmellFilter.



19
20
21
# File 'lib/pronto/rubycritic/smell_filter.rb', line 19

def initialize(config)
  @config = config.is_a?(Hash) ? config : {}
end

Instance Method Details

#call(modules) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/pronto/rubycritic/smell_filter.rb', line 23

def call(modules)
  # Fast path: an empty/nil config is semantically transparent — never
  # mutate input modules, never call mod.smells=. This lets the filter
  # be chained harmlessly.
  return Array(modules) if @config.empty?

  Array(modules).filter_map { |mod| filter_module(mod) }
end