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

Error with Layout/SpaceInsideArrayLiteralBrackets #5637

Closed
QuentinFchx opened this issue Mar 6, 2018 · 0 comments · Fixed by #5658
Closed

Error with Layout/SpaceInsideArrayLiteralBrackets #5637

QuentinFchx opened this issue Mar 6, 2018 · 0 comments · Fixed by #5658
Labels

Comments

@QuentinFchx
Copy link

When inspecting code such as:

module Foo
    def bar
        ActiveRecord::Base.connection.execute(<<-SQL).hmap { |row| [row['name'], row['count'].to_i] }
            SELECT
                name,
                COUNT(DISTINCT baz.id) AS count
            FROM foo
        SQL
    end
end

Expected behavior

The linter should work

Actual behavior

undefined method '+' for nil:NilClass is thrown.

ruby/2.5.0/gems/rubocop-0.53.0/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb:122:in `next_to_newline?'
ruby/2.5.0/gems/rubocop-0.53.0/lib/rubocop/cop/layout/space_inside_array_literal_brackets.rb:79:in `on_array'

Steps to reproduce the problem

See code snippet above.

RuboCop version

0.53.0 (using Parser 2.5.0.3, running on ruby 2.5.0 x86_64-darwin17)

@pocke pocke added the bug label Mar 6, 2018
koic added a commit to koic/rubocop that referenced this issue Mar 9, 2018
…ets`

Fixes rubocop#5637.

This PR reverts part of the optimized implementation by rubocop#5373. As a result,
the performance will be that before the optimization, but it will fix
the regression.
Also, this PR adds a regression tests. First of all, after fix
the regression of rubocop#5373 with this PR, it is good to do optimization that
passes the added regression tests.
bbatsov pushed a commit that referenced this issue Mar 10, 2018
Fixes #5637.

This PR reverts part of the optimized implementation by #5373. As a result,
the performance will be that before the optimization, but it will fix
the regression.
Also, this PR adds a regression tests. First of all, after fix
the regression of #5373 with this PR, it is good to do optimization that
passes the added regression tests.
This was referenced Mar 21, 2018
This was referenced Mar 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants