seattlerb/debride

An error occurred while executing a command for a Rails app for the app directory

Closed this issue · 4 comments

afuno commented

In a project under Rails 7.0.4.3, I ran this command:

debride --rails app

As a result I got an error:

/Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/debride-1.11.0/lib/debride.rb:349:in `process_block_pass': undefined method `sexp_type' for nil:NilClass (NoMethodError)

    case name.sexp_type
             ^^^^^^^^^^
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:269:in `block (2 levels) in process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:324:in `error_handler'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:268:in `block in process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:388:in `in_context'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:245:in `process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:692:in `process_until_empty'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/debride-1.11.0/lib/debride.rb:341:in `process_call'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:269:in `block (2 levels) in process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:324:in `error_handler'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:268:in `block in process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:388:in `in_context'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:245:in `process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:692:in `process_until_empty'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/debride-1.11.0/lib/debride.rb:423:in `block in process_defn'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:626:in `block in process_defn'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:553:in `in_method'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:624:in `process_defn'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/debride-1.11.0/lib/debride.rb:421:in `process_defn'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:269:in `block (2 levels) in process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:324:in `error_handler'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:268:in `block in process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:388:in `in_context'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:245:in `process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:692:in `process_until_empty'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:663:in `block in process_module'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:539:in `block in in_klass'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:710:in `with_new_method_stack'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:538:in `in_klass'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:659:in `process_module'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:269:in `block (2 levels) in process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:324:in `error_handler'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:268:in `block in process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:388:in `in_context'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/sexp_processor-4.17.0/lib/sexp_processor.rb:245:in `process'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/debride-1.11.0/lib/debride.rb:81:in `block in run'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/debride-1.11.0/lib/debride.rb:68:in `each'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/debride-1.11.0/lib/debride.rb:68:in `run'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/debride-1.11.0/lib/debride.rb:63:in `run'
        from /Users/afuno/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/debride-1.11.0/bin/debride:5:in `<top (required)>'
        from /Users/afuno/.rbenv/versions/3.2.2/bin/debride:25:in `load'
        from /Users/afuno/.rbenv/versions/3.2.2/bin/debride:25:in `<main>'

I've got a new version of debride that I'm JUST about to release. I'd love to make sure this is fixed before I do.

Any chance you can share the code (abstracted however you'd like) that reproduces this? I can help you hunt it down.

There's gonna be some sort of "block pass", eg (collection.map(&:to_s) or collection.map { ... }). It's inside a method, so it isn't class level. You can run with --verbose to quickly figure out which file it is.

afuno commented

@zenspider The project has a concern that is created using this:

extend ActiveSupport::Concern

Inside this concern class, I checked all the methods. As a result, I noticed that your gem crashes only on this method in the file:

def with_locale(&)
  I18n.with_locale(I18n.locale, &)
end
afuno commented

Thaaanks. Everything is successful.