File tree Expand file tree Collapse file tree 6 files changed +35
-10
lines changed
lib/rubycritic/analysers/smells Expand file tree Collapse file tree 6 files changed +35
-10
lines changed Original file line number Diff line number Diff line change 11---
2+ exclude_paths :
3+ - test/samples/reek/excluded.rb
24detectors :
35 InstanceVariableAssumption :
46 exclude :
Original file line number Diff line number Diff line change 66* [ FEATURE] ...
77
88* [ CHORE] Uses prism instead of parser for Ruby 3.4 and above (by [ @torresga ] [ ] and [ @julioalucero ] [ ] )
9+ * [ BUGFIX] Respect excluded paths from .reek configuration file during reek analysis (by [ @fbuys ] [ ] )
910
1011# v4.11.0 / 2025-10-15 [ (commits)] ( https://github.com/whitesmith/rubycritic/compare/v4.10.0...v4.11.0 )
1112
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ class ReekSmells
1010 include Colorize
1111
1212 def initialize ( analysed_modules )
13- @analysed_modules = analysed_modules
13+ @analysed_modules = analysed_modules . reject { Reek . configuration . path_excluded? ( _1 . pathname ) }
1414 end
1515
1616 def run
Original file line number Diff line number Diff line change 66describe RubyCritic ::Analyser ::ReekSmells do
77 context 'when analysing a smelly file' do
88 before do
9- pathname = Pathname . new ( 'test/samples/reek/smelly.rb' )
10- @analysed_module = AnalysedModuleDouble . new ( pathname : pathname , smells : [ ] )
11- analysed_modules = [ @analysed_module ]
9+ # Reset Reek configuration between tests
10+ # Config is cached and can leak between tests
11+ RubyCritic ::Reek . instance_variable_set ( :@configuration , nil )
12+
13+ analysed_path = Pathname . new ( 'test/samples/reek/smelly.rb' )
14+ @analysed_module = AnalysedModuleDouble . new ( pathname : analysed_path , smells : [ ] )
15+
16+ excluded_path = Pathname . new ( 'test/samples/reek/excluded.rb' )
17+ @excluded_module = AnalysedModuleDouble . new ( pathname : excluded_path , smells : [ ] )
18+
19+ analysed_modules = [ @analysed_module , @excluded_module ]
1220 RubyCritic ::Analyser ::ReekSmells . new ( analysed_modules ) . run
1321 end
1422
2230 _ ( messages ) . wont_include "has the parameter name 'a'"
2331 end
2432
33+ it 'ignores excluded files' do
34+ _ ( @excluded_module . smells ) . must_be :empty?
35+ end
36+
2537 it 'creates smells with messages' do
2638 first_smell = @analysed_module . smells . first
2739
Original file line number Diff line number Diff line change 33require 'test_helper'
44require 'rubycritic/analysers_runner'
55require 'rubycritic/generators/lint_report'
6- require 'fakefs/safe'
76
87describe RubyCritic ::Generator ::LintReport do
98 describe '#generate_report' do
10- around do | example |
11- capture_output_streams do
12- with_cloned_fs ( & example )
13- end
9+ before do
10+ # Reset Reek configuration between tests
11+ # Config is cached and can leak between tests
12+ RubyCritic :: Reek . instance_variable_set ( :@configuration , nil )
1413 end
1514
1615 it 'report file has data inside' do
17- sample_files = Dir [ 'test/samples/**/*.rb' ] . reject { |f | File . empty? ( f ) }
16+ sample_files = Dir [ 'test/samples/**/*.rb' ] . reject { |f | File . empty? ( f ) || f . include? ( 'excluded' ) }
1817 create_analysed_modules_collection
1918 generate_report
2019 lines = File . readlines ( 'test/samples/lint.txt' ) . map ( &:strip ) . reject ( &:empty? )
Original file line number Diff line number Diff line change 1+ class Tyrion
2+ def reeks? ( reek = true )
3+ reek
4+ end
5+
6+ def flayed? ( a )
7+ a
8+ end
9+ end
10+
11+ # Reek should exclude this file entirely based on the .reek.yml configuration
You can’t perform that action at this time.
0 commit comments