rufo icon indicating copy to clipboard operation
rufo copied to clipboard

formatter.rb:1286:in `visit_command_args': undefined method `[]' for nil:NilClass (NoMethodError)

Open josbraaksma opened this issue 2 years ago • 1 comments

formatter.rb:1286:in visit_command_args': undefined method []' for nil:NilClass (NoMethodError)

on code

      my_array = input_array.lazy 
        .map &method(:my_method) # <==== I believe this causes an issue
        .select { |c| condition(c) }
        .map do |c| 
          # do stuff with
          c
        end
        .compact
        .sort_by { |c| -c[:confidence].to_f }  # <==== rufo complains here

traceback

Traceback (most recent call last):
        72: from /home/jos/.ruby/bin/rufo:23:in `<main>'
        71: from /home/jos/.ruby/bin/rufo:23:in `load'
        70: from /home/jos/.ruby/gems/rufo-0.13.0/exe/rufo:4:in `<top (required)>'
        69: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/command.rb:12:in `run'
        68: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/command.rb:40:in `run'
        67: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/command.rb:78:in `format_args'
        66: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/command.rb:78:in `each'
        65: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/command.rb:85:in `block in format_args'
        64: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/command.rb:107:in `format_file'
        63: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/command.rb:146:in `format'
        62: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:177:in `format'
        61: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:201:in `visit'
        60: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `visit_exps'
        59: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `each_with_index'
        58: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `each'
        57: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:525:in `block in visit_exps'
        56: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3699:in `push_node'
        55: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:526:in `block (2 levels) in visit_exps'
        54: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:400:in `visit'
        53: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1983:in `visit_module'
        52: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3714:in `push_type'
        51: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1990:in `block in visit_module'
        50: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:380:in `visit'
        49: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1578:in `visit_bodystmt'
        48: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3466:in `indent_body'
        47: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3391:in `indent'
        46: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3467:in `block in indent_body'
        45: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `visit_exps'
        44: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `each_with_index'
        43: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `each'
        42: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:525:in `block in visit_exps'
        41: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3699:in `push_node'
        40: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:526:in `block (2 levels) in visit_exps'
        39: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:398:in `visit'
        38: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1957:in `visit_class'
        37: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3714:in `push_type'
        36: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1973:in `block in visit_class'
        35: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:380:in `visit'
        34: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1578:in `visit_bodystmt'
        33: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3466:in `indent_body'
        32: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3391:in `indent'
        31: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3467:in `block in indent_body'
        30: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `visit_exps'
        29: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `each_with_index'
        28: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `each'
        27: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:525:in `block in visit_exps'
        26: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3699:in `push_node'
        25: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:526:in `block (2 levels) in visit_exps'
        24: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:410:in `visit'
        23: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:2004:in `visit_def'
        22: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3707:in `push_hash'
        21: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:2005:in `block in visit_def'
        20: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:2088:in `visit_def_from_name'
        19: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:380:in `visit'
        18: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1578:in `visit_bodystmt'
        17: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3466:in `indent_body'
        16: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3391:in `indent'
        15: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3467:in `block in indent_body'
        14: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `visit_exps'
        13: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `each_with_index'
        12: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:504:in `each'
        11: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:525:in `block in visit_exps'
        10: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3699:in `push_node'
         9: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:526:in `block (2 levels) in visit_exps'
         8: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:327:in `visit'
         7: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:837:in `visit_assign'
         6: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:908:in `visit_assign_value'
         5: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:3566:in `indent_after_space'
         4: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:368:in `visit'
         3: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1353:in `visit_call_with_block'
         2: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:353:in `visit'
         1: from /home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1258:in `visit_command_call'
/home/jos/.ruby/gems/rufo-0.13.0/lib/rufo/formatter.rb:1286:in `visit_command_args': undefined method `[]' for nil:NilClass (NoMethodError)

josbraaksma avatar Aug 29 '22 14:08 josbraaksma

maybe same as #264

kzkn avatar Mar 19 '23 05:03 kzkn