rubycritic icon indicating copy to clipboard operation
rubycritic copied to clipboard

Reek configuration not being picked up

Open jgrau opened this issue 8 years ago • 7 comments

With a fresh gem install of rubycritic and a run with rubycritic --no-browser --minimum-score 85 --path critique app lib config script test in my rails project I get a score of 89.72.

Running reek --todo which correctly generates a .todo.reek file with a lot of ignores, I would expect the subsequent run of rubycritic would give me a higher score. However, I get the exact same score. Checking the report I see a lot of smells which should have been ignored.

Running reek app lib config script test correctly displays 0 warnings

|            | Version |
|------------|---------|
| Ruby       | 2.2.3   |
| RubyCritic | 2.9.4   |
| Reek       | 4.4.1   |

jgrau avatar Oct 07 '16 16:10 jgrau

It seems that the instantiate a Reek::Examiner without any options. That loads a default configuration using Reek::Configuration::AppConfiguration.default but that does not trigger the config file loading.

Reek's CLI passes to the examiner the result of Reek::Configuration::AppConfiguration.from_path(config_file) for the config file handling.

mereghost avatar Oct 30 '16 05:10 mereghost

Yeah, that's most certainly a bug. Pull requests welcome!

troessner avatar Oct 31 '16 09:10 troessner

Any contribution guidelines that I must be aware of before sending you folks a PR?

mereghost avatar Oct 31 '16 13:10 mereghost

Check out Contributing

troessner avatar Oct 31 '16 14:10 troessner

I see there was a PR for this bug (https://github.com/whitesmith/rubycritic/pull/175), but it seems to still be a problem:

$ cat .reek
---
exclude_paths:
  - lib/templates
$ reek lib/templates      
Inspecting 0 file(s):


$ rubycritic lib/templates
  lib/templates/active_record/model/model.rb:1 :: parse error on value "<" (tLT)
  skipping lib/templates/active_record/model/model.rb
running flay smells

running flog smells
#<Racc::ParseError: lib/templates/active_record/model/model.rb:1 :: parse error on value "<" (tLT)> at /Users/joneshf/.rubies/ruby-2.3.3/lib/ruby/2.3.0/racc/parser.rb:528:in `on_error', /Users/joneshf/.gem/ruby/2.3.3/gems/ruby_parser-3.9.0/lib/ruby_parser_extras.rb:1163:in `on_error', /Users/joneshf/.rubies/ruby-2.3.3/lib/ruby/2.3.0/racc/parser.rb:259:in `_racc_do_parse_c', /Users/joneshf/.rubies/ruby-2.3.3/lib/ruby/2.3.0/racc/parser.rb:259:in `do_parse', /Users/joneshf/.gem/ruby/2.3.3/gems/ruby_parser-3.9.0/lib/ruby_parser_extras.rb:1075:in `block in process'

...stupid lemmings and their bad erb templates... skipping
.
running reek smells
/Users/joneshf/.gem/ruby/2.3.3/gems/reek-4.6.2/lib/reek/source/source_code.rb:96:in `rescue in syntax_tree': lib/templates/active_record/model/model.rb: Parser::SyntaxError: unexpected token tLT (Reek::Errors::ParseError)
	from /Users/joneshf/.gem/ruby/2.3.3/gems/reek-4.6.2/lib/reek/source/source_code.rb:93:in `syntax_tree'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/reek-4.6.2/lib/reek/examiner.rb:110:in `syntax_tree'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/reek-4.6.2/lib/reek/examiner.rb:100:in `run'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/reek-4.6.2/lib/reek/examiner.rb:67:in `smells'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/analysers/smells/reek.rb:30:in `add_smells_to'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/analysers/smells/reek.rb:17:in `block in run'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/core/analysed_modules_collection.rb:27:in `each'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/core/analysed_modules_collection.rb:27:in `each'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/analysers/smells/reek.rb:16:in `run'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/analysers_runner.rb:30:in `block in run'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/analysers_runner.rb:27:in `each'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/analysers_runner.rb:27:in `run'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/commands/default.rb:24:in `critique'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/commands/default.rb:19:in `execute'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/lib/rubycritic/cli/application.rb:20:in `execute'
	from /Users/joneshf/.gem/ruby/2.3.3/gems/rubycritic-3.2.2/bin/rubycritic:10:in `<top (required)>'
	from /Users/joneshf/.gem/ruby/2.3.3/bin/rubycritic:22:in `load'
	from /Users/joneshf/.gem/ruby/2.3.3/bin/rubycritic:22:in `<main>'
Version
Ruby 2.3.3
RubyCritic 3.2.2
Reek 4.6.2

Any thoughts on what's going wrong and how to fix it?

joneshf avatar May 20 '17 20:05 joneshf

Rubycritic is still ignoring the .reek.yml file with:

  • Ruby 2.5.3
  • RubyCritic 4.0.2
  • Reek 5.3.2

See my note here: https://github.com/whitesmith/rubycritic/issues/270#issuecomment-494965772

philCryoport avatar May 22 '19 22:05 philCryoport

Hey @philCryoport is Rubycritic still not picking up your .reek.yml? I just added a .reek.yml to my project and it is working. ruby version: 2.6.3 My Gemfile.lock:

    rubycritic (4.4.0)
      flay (~> 2.8)
      flog (~> 4.4)
      launchy (= 2.4.3)
      parser (>= 2.6.0)
      rainbow (~> 3.0)
      reek (~> 5.0, < 6.0)
      ruby_parser (~> 3.8)
      simplecov (>= 0.17.0)
      tty-which (~> 0.4.0)
      virtus (~> 1.0)

My .reek.yml:

directories:
  "app/controllers":
    IrresponsibleModule:
      enabled: false
    NestedIterators:
      max_allowed_nesting: 2
    UnusedPrivateMethod:
      enabled: false
    InstanceVariableAssumption:
      enabled: false
  "app/helpers":
    IrresponsibleModule:
      enabled: false
    UtilityFunction:
      enabled: false
  "app/models":
    InstanceVariableAssumption:
      enabled: false

jo-quin avatar Feb 23 '20 16:02 jo-quin