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

Style/AlignHash error when using EnforcedColonStyle: table #3908

Closed
backus opened this issue Jan 16, 2017 · 2 comments
Closed

Style/AlignHash error when using EnforcedColonStyle: table #3908

backus opened this issue Jan 16, 2017 · 2 comments

Comments

@backus
Copy link
Contributor

backus commented Jan 16, 2017

Config

Style/AlignHash:
  EnforcedColonStyle: table

Source

def foo(**kw)
  new(
    a: 1,
    **kw
  )
end

Reproduction

$ cat rubocop.yml
Style/AlignHash:
  EnforcedColonStyle: table

$ cat ex.rb
def foo(**kw)
  new(
    a: 1,
    **kw
  )
end

$ rubocop -V
0.47.0 (using Parser 2.3.3.1, running on ruby 2.4.0 x86_64-darwin16)

$ rubocop -c rubocop.yml ex.rb -d
configuration from /dev/project/rubocop.yml
Default configuration from /Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/config/default.yml
Inheriting configuration from /Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/config/enabled.yml
Inheriting configuration from /Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/config/disabled.yml
Inspecting 1 file
Scanning /dev/project/ex.rb
An error occurred while Style/AlignHash cop was inspecting /dev/project/ex.rb:3:4.
undefined method `delimiter' for "s(:kwsplat,\n  s(:lvar, :kw))":RuboCop::AST::KeywordSplatNode
Did you mean?  delimiter_delta
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/mixin/hash_alignment.rb:84:in `value_delta'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/mixin/hash_alignment.rb:36:in `deltas'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/style/align_hash.rb:143:in `block in check_pairs'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/style/align_hash.rb:141:in `each'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/style/align_hash.rb:141:in `check_pairs'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/style/align_hash.rb:124:in `on_hash'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/commissioner.rb:43:in `block (2 levels) in on_hash'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/commissioner.rb:102:in `with_cop_error_handling'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/commissioner.rb:42:in `block in on_hash'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/commissioner.rb:41:in `each'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/commissioner.rb:41:in `on_hash'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/ast/traversal.rb:101:in `block in on_send'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/ast/traversal.rb:99:in `each'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/ast/traversal.rb:99:in `each_with_index'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/ast/traversal.rb:99:in `on_send'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/commissioner.rb:47:in `on_send'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/ast/traversal.rb:95:in `on_def'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/commissioner.rb:47:in `on_def'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/ast/traversal.rb:12:in `walk'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/commissioner.rb:60:in `investigate'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/team.rb:121:in `investigate'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/team.rb:109:in `offenses'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cop/team.rb:51:in `inspect_file'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:248:in `inspect_file'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:195:in `block in do_inspection_loop'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:227:in `block in iterate_until_no_changes'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:220:in `loop'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:220:in `iterate_until_no_changes'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:191:in `do_inspection_loop'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:101:in `block in file_offenses'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:111:in `file_offense_cache'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:99:in `file_offenses'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:90:in `process_file'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:68:in `block in each_inspected_file'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:65:in `each'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:65:in `reduce'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:65:in `each_inspected_file'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:57:in `inspect_files'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/runner.rb:36:in `run'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cli.rb:72:in `execute_runner'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/lib/rubocop/cli.rb:27:in `run'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/bin/rubocop:13:in `block in <top (required)>'
/Users/johnbackus/.rubies/ruby-2.4.0/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'
/Users/johnbackus/.gem/ruby/2.4.0/gems/rubocop-0.47.0/bin/rubocop:12:in `<top (required)>'
/Users/johnbackus/.gem/ruby/2.4.0/bin/rubocop:22:in `load'
/Users/johnbackus/.gem/ruby/2.4.0/bin/rubocop:22:in `<main>'
C

Offenses:

ex.rb:1:1: C: Style/FrozenStringLiteralComment: Missing frozen string literal comment.
def foo(**kw)
^

1 file inspected, 1 offense detected

1 error occurred:
An error occurred while Style/AlignHash cop was inspecting /dev/project/ex.rb:3:4.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
Mention the following information in the issue report:
0.47.0 (using Parser 2.3.3.1, running on ruby 2.4.0 x86_64-darwin16)
Finished in 0.14244399999734014 seconds
@Drenmi
Copy link
Collaborator

Drenmi commented Jan 16, 2017

Thanks @backus! Will look into it. 😀

Drenmi added a commit to Drenmi/rubocop that referenced this issue Jan 16, 2017
…rd splat when using enforced `table` style

After refactoring, a regression was introduced that would cause this cop
to break under the following conditions:

 - Enforced style is set to: `table`
 - Hash does not contain mixed keys
 - Hash contains a keyword splat element

This change fixes that.
@Drenmi
Copy link
Collaborator

Drenmi commented Jan 16, 2017

@backus: Found a specific set of conditions that weren't covered by tests. 😞 I just opened a bugfix PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants