We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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/TrailingCommaInBlockArgs
NoMethodError is not occurred.
$ echo '-> (v1, v2) { puts v1 + v2 }' | rubocop --stdin foo.rb --only Style/TrailingCommaInBlockArgs Inspecting 1 file . 1 file inspected, no offenses detected
NoMethodError is occurred.
$ echo '-> (v1, v2) { puts v1 + v2 }' | rubocop --debug --stdin foo.rb --only Style/TrailingCommaInBlockArgs For /home/yujideveloper: configuration from /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/config/default.yml Inspecting 1 file Scanning /home/yujideveloper/foo.rb An error occurred while Style/TrailingCommaInBlockArgs cop was inspecting /home/yujideveloper/foo.rb:1:0. undefined method `+' for nil:NilClass /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/style/trailing_comma_in_block_args.rb:80:in `argument_tokens' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/style/trailing_comma_in_block_args.rb:67:in `trailing_comma?' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/style/trailing_comma_in_block_args.rb:59:in `useless_trailing_comma?' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/style/trailing_comma_in_block_args.rb:47:in `on_block' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/commissioner.rb:57:in `block (2 levels) in trigger_responding_cops' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/commissioner.rb:136:in `with_cop_error_handling' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/commissioner.rb:56:in `block in trigger_responding_cops' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/commissioner.rb:55:in `each' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/commissioner.rb:55:in `trigger_responding_cops' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/commissioner.rb:32:in `block (2 levels) in <class:Commissioner>' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/ast/traversal.rb:14:in `walk' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/commissioner.rb:44:in `investigate' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/team.rb:124:in `investigate' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/team.rb:112:in `offenses' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cop/team.rb:44:in `inspect_file' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:296:in `inspect_file' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:244:in `block in do_inspection_loop' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:276:in `block in iterate_until_no_changes' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:269:in `loop' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:269:in `iterate_until_no_changes' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:240:in `do_inspection_loop' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:119:in `block in file_offenses' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:143:in `file_offense_cache' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:117:in `file_offenses' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:108:in `process_file' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:87:in `block in each_inspected_file' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:86:in `each' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:86:in `reduce' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:86:in `each_inspected_file' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:73:in `inspect_files' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/runner.rb:39:in `run' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cli/command.rb:10:in `run' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cli/environment.rb:17:in `run' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cli.rb:65:in `run_command' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cli.rb:72:in `execute_runners' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/lib/rubocop/cli.rb:41:in `run' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/exe/rubocop:13:in `block in <top (required)>' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/2.5.0/benchmark.rb:308:in `realtime' /home/yujideveloper/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/rubocop-0.81.0/exe/rubocop:12:in `<top (required)>' /home/yujideveloper/.rbenv/versions/2.5.7/bin/rubocop:23:in `load' /home/yujideveloper/.rbenv/versions/2.5.7/bin/rubocop:23:in `<main>' . 1 file inspected, no offenses detected 1 error occurred: An error occurred while Style/TrailingCommaInBlockArgs cop was inspecting /home/yujideveloper/foo.rb:1:0. Errors are usually caused by RuboCop bugs. Please, report your problems to RuboCop's issue tracker. https://github.com/rubocop-hq/rubocop/issues Mention the following information in the issue report: 0.81.0 (using Parser 2.7.0.5, running on ruby 2.5.7 x86_64-linux) Finished in 0.26879936900149914 seconds
$ echo '-> (v1, v2) { puts v1 + v2 }' | rubocop --debug --stdin foo.rb --only Style/TrailingCommaInBlockArgs
$ rubocop -V 0.81.0 (using Parser 2.7.0.5, running on ruby 2.5.7 x86_64-linux)
The text was updated successfully, but these errors were encountered:
[Fix rubocop#7841] Fix an error for Style/TrailingCommaInBlockArgs cop
6169ce3
Fixes rubocop#7841. This PR fixes an error for `Style/TrailingCommaInBlockArgs` cop when lambda literal (`->`) has multiple arguments. It will not be checked in the case of lambda literal because lambda literal (`->`) never have a block arguments. ```console # Valid syntax % ruby -ce '-> (foo, bar) { do_something(foo, bar) }' Syntax OK # Syntax error % ruby -ce '-> { |foo| do_something }' -e:1: syntax error, unexpected '|' -> { |foo| do_something } ^ # Also syntax error % ruby -ce '-> (foo, bar,) { do_something(foo, bar) }' -e:1: syntax error, unexpected ')' -> (foo, bar,) { do_something(foo, bar) } ^ -e:1: syntax error, unexpected '}', expecting end-of-input r,) { do_something(foo, bar) } ^ ```
Merge pull request #7843 from koic/fix_error_for_style_trailing_comma…
28f18ac
…_in_block_args [Fix #7841] Fix an error for `Style/TrailingCommaInBlockArgs` cop
Successfully merging a pull request may close this issue.
Expected behavior
NoMethodError is not occurred.
Actual behavior
NoMethodError is occurred.
Steps to reproduce the problem
RuboCop version
The text was updated successfully, but these errors were encountered: