Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an error for Lint/UselessTimes #8739

Merged
merged 1 commit into from Sep 17, 2020

Commits on Sep 17, 2020

  1. Fix an error for Lint/UselessTimes

    This PR fixes the following error for `Lint/UselessTimes`
    when using empty block argument.
    
    ```console
    % cat example.rb
    def foo
      1.times do
      end
    end
    
    % rubocop --only Lint/UselessTimes -d
    (snip)
    
    Inspecting 1 file
    Scanning /Users/koic/src/github.com/koic/rubocop-issues/bar/example.rb
    An error occurred while Lint/UselessTimes cop was inspecting
    /Users/koic/src/github.com/koic/rubocop-issues/bar/example.rb:2:2.
    undefined method `source' for nil:NilClass
    /Users/koic/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/
    lib/rubocop/cop/lint/useless_times.rb:76:in `autocorrect_block'
    /Users/koic/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/
    lib/rubocop/cop/lint/useless_times.rb:57:in `block in on_send'
    /Users/koic/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/
    lib/rubocop/cop/base.rb:333:in `correct'
    /Users/koic/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/
    lib/rubocop/cop/base.rb:126:in `add_offense'
    /Users/koic/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/rubocop-0.91.0/
    lib/rubocop/cop/lint/useless_times.rb:49:in `on_send'
    ```
    koic committed Sep 17, 2020
    Copy the full SHA
    8e8a320 View commit details
    Browse the repository at this point in the history