reek icon indicating copy to clipboard operation
reek copied to clipboard

Intentionaly unparseable file can't be excluded?

Open pboling opened this issue 5 months ago • 4 comments

My reek.yml has:

exclude_paths:
  - vendor/

And when I run bundle exec reek I get:

        !!!
        Source 'vendor/another/ruby/3.4.0/bundler/gems/yard-junk-54ccebabbfa9/examples/input/unparseable.rb' cannot be processed by Reek due to a syntax error in the source file.

        This is a problem that is outside of Reek's scope and should be fixed by you, the
        user, in order for Reek being able to continue.

        Things you can try:
        - Check the syntax of the problematic file
        - If the file is not in fact a Ruby file, exclude it in your .reek.yml file

        Exception message:

        #<Parser::SyntaxError: unexpected token tNL>

        Original backtrace:

        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/parser-3.3.9.0/lib/parser/diagnostic/engine.rb:72:in 'Parser::Diagnostic::Engine#process'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/parser-3.3.9.0/lib/parser/base.rb:289:in 'Parser::Base#on_error'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/racc-1.8.1/lib/racc/parser.rb:263:in 'Racc::Parser#_racc_do_parse_c'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/racc-1.8.1/lib/racc/parser.rb:263:in 'Racc::Parser#do_parse'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/parser-3.3.9.0/lib/parser/base.rb:193:in 'Parser::Base#parse'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/parser-3.3.9.0/lib/parser/base.rb:210:in 'Parser::Base#parse_with_comments'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/source/source_code.rb:123:in 'Reek::Source::SourceCode#parse'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/source/source_code.rb:53:in 'Reek::Source::SourceCode#syntax_tree'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/examiner.rb:116:in 'Reek::Examiner#syntax_tree'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/examiner.rb:120:in 'Reek::Examiner#examine_tree'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/examiner.rb:94:in 'block in Reek::Examiner#run'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/examiner.rb:104:in 'Reek::Examiner#wrap_exceptions'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/examiner.rb:93:in 'Reek::Examiner#run'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/examiner.rb:61:in 'Reek::Examiner#smells'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/examiner.rb:69:in 'Reek::Examiner#smells_count'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/report/base_report.rb:44:in 'Reek::Report::BaseReport#add_examiner'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/report/text_report.rb:23:in 'Reek::Report::TextReport#add_examiner'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/cli/command/report_command.rb:26:in 'block in Reek::CLI::Command::ReportCommand#populate_reporter_with_smells'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/cli/command/report_command.rb:25:in 'Array#each'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/cli/command/report_command.rb:25:in 'Reek::CLI::Command::ReportCommand#populate_reporter_with_smells'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/cli/command/report_command.rb:17:in 'Reek::CLI::Command::ReportCommand#execute'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/lib/reek/cli/application.rb:32:in 'Reek::CLI::Application#execute'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/reek-6.5.0/bin/reek:12:in '<top (required)>'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/rubygems.rb:319:in 'Kernel#load'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/rubygems.rb:319:in 'Gem.activate_and_load_bin_path'
        /home/pboling/.local/share/mise/installs/ruby/3.4.5/bin/reek:25:in '<top (required)>'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/cli/exec.rb:59:in 'Kernel.load'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/cli/exec.rb:59:in 'Bundler::CLI::Exec#kernel_load'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/cli/exec.rb:23:in 'Bundler::CLI::Exec#run'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/cli.rb:451:in 'Bundler::CLI#exec'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/vendor/thor/lib/thor/command.rb:28:in 'Bundler::Thor::Command#run'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/vendor/thor/lib/thor/invocation.rb:127:in 'Bundler::Thor::Invocation#invoke_command'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/vendor/thor/lib/thor.rb:538:in 'Bundler::Thor.dispatch'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/cli.rb:35:in 'Bundler::CLI.dispatch'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/vendor/thor/lib/thor/base.rb:584:in 'Bundler::Thor::Base::ClassMethods#start'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/cli.rb:29:in 'Bundler::CLI.start'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/bundler-2.7.1/exe/bundle:28:in 'block in <top (required)>'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/bundler/friendly_errors.rb:118:in 'Bundler.with_friendly_errors'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/gems/3.4.0/gems/bundler-2.7.1/exe/bundle:20:in '<top (required)>'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/rubygems.rb:319:in 'Kernel#load'
        /var/home/pboling/.local/share/mise/installs/ruby/3.4.5/lib/ruby/site_ruby/3.4.0/rubygems.rb:319:in 'Gem.activate_and_load_bin_path'
        /home/pboling/.local/share/mise/installs/ruby/3.4.5/bin/bundle:25:in '<main>'

        !!!

The unparseable file @ vendor/another/ruby/3.4.0/bundler/gems/yard-junk-54ccebabbfa9/examples/input/unparseable.rb should have been excluded by the exclude_paths setting.

Alternative configs I tried:

exclude_paths:
  - vendor/*
exclude_paths:
  - vendor/**/*
exclude_paths:
  - vendor/another/ruby/3.4.0/bundler/gems/yard-junk-54ccebabbfa9/examples/input/unparseable.rb

But all give the same exact result.

This may be related, at least thematically, to https://github.com/troessner/reek/issues/1429.

pboling avatar Jul 28 '25 02:07 pboling

Hey @pboling

thanks for the bug report, I'm a bit busy right now but when I get a free moment I'll look into this!

troessner avatar Aug 17 '25 12:08 troessner

I'll take a stab at this

fbuys avatar Oct 23 '25 13:10 fbuys

Here are the steps I followed to attempt to replicate the reported issue.

  • Used Ruby 3.3 and 3.4.
  • Installed reek using gem install reek and installed version 6.5.0 (same version shown in issue report).

Without ignoring anything I see:

        Source 'app/controllers/forms_controller.rb' cannot be processed by Reek due to a syntax error in the source file.

        This is a problem that is outside of Reek's scope and should be fixed by you, the
        user, in order for Reek being able to continue.

        Things you can try:
        - Check the syntax of the problematic file
        - If the file is not in fact a Ruby file, exclude it in your .reek.yml file

        Exception message:

        #<Parser::SyntaxError: unexpected token tCOMMA>

In this case the forms_controller contains invalid syntax.

I add a .reek.yml file with:

exclude_paths:
  - app/controllers/forms_controller.rb

or

exclude_paths:
  - app/controllers/

Result

Once I add either of the exclude statements above I no longer see the parse error.

When I try to run reek on the particular controller, I still don't see the parse error:

❯ reek app/controllers/forms_controller.rb
Inspecting 0 file(s):

@pboling are there perhaps any additional steps you would suggest I take to attempt to replicate the issue you experienced?

fbuys avatar Oct 23 '25 14:10 fbuys

Is it possible that the issue lies specifically with a "vendor" exclusion?

I will try to create a minimal reproduction.

pboling avatar Oct 23 '25 18:10 pboling