Shopify/smart_todo

Crash on # TODO?

Closed this issue · 1 comments

The smart todo parser crashes when the comment contains # TODO?

To reproduce add the following test to smart_todo_cop_test.rb:

    def test_add_offense_when_todo_has_question_mark
      expect_offense(<<~RUBY)
      # TODO?
      RUBY
    end

Stacktrace:

NoMethodError: undefined method `[]' for #<SmartTodo::Parser::MethodNode:0x0000000126188518 @arguments=nil, @method_name="TODO?">
    /Users/martinwallace/src/github.com/Shopify/smart_todo/lib/smart_todo/parser/metadata_parser.rb:96:in `process'
    /Users/martinwallace/src/github.com/Shopify/smart_todo/lib/smart_todo/parser/metadata_parser.rb:24:in `block in parse'
    <internal:kernel>:90:in `tap'
    /Users/martinwallace/src/github.com/Shopify/smart_todo/lib/smart_todo/parser/metadata_parser.rb:24:in `parse'

I'll try to open up a PR to fix this later, just logging the issue for now.