$ docker run --rm -it mtsmfm/ruby-trunk:alpine ruby -v
ruby 2.6.0dev (2018-05-15) [x86_64-linux-musl]
$ docker run --rm -it -v $PWD/test:/test mtsmfm/ruby-trunk:alpine ruby -W2 /test/asdf.rb
Last active
May 15, 2018 14:34
-
-
Save SpComb/483b2e36ce80c52aa48f9e76cfe4f612 to your computer and use it in GitHub Desktop.
ruby 2.6 warnings vs rubocop linter checks re ruby 3 keyword argument changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def foo(arg, options = {}) | |
| puts "foo(#{arg.inspect}, #{options.inspect})" | |
| end | |
| def bar(arg, **options) | |
| puts "bar(#{arg.inspect}, **#{options.inspect})" | |
| end | |
| def asdf(arg, test: nil) | |
| puts "asdf(#{arg.inspect}, test: #{test.inspect})" | |
| end | |
| options = { test: true } | |
| foo('a', options) # valid | |
| foo('a', **options) # ruby 2.6 warning, rubocop warning, invalid for ruby3? | |
| foo('a', test: true) # invalid for ruby3? | |
| foo('a', **options, test: false) # ruby 2.6 warning, rubocop warning, invalid for ruby3? | |
| bar('b', options) # invalid for ruby3? | |
| bar('b', **options) # valid, rubocop warning | |
| bar('b', test: true) # valid | |
| bar('b', **options, test: false) # valid, rubocop warning | |
| asdf('c', options) # invalid for ruby3? | |
| asdf('c', **options) # valid, rubocop warning | |
| asdf('c', test: true) # valid | |
| asdf('c', **options, test: false) # valid, rubocop warning |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Inspecting 1 file | |
| W | |
| Offenses: | |
| test/asdf.rb:1:1: C: Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true. | |
| def foo(arg, options = {}) | |
| ^ | |
| test/asdf.rb:16:10: W: Lint/SplatKeywordArguments: Do not use splat keyword arguments as a single Hash. | |
| foo('a', **options) | |
| ^^^^^^^^^ | |
| test/asdf.rb:18:10: W: Lint/SplatKeywordArguments: Do not use splat keyword arguments as a single Hash. | |
| foo('a', **options, test: false) | |
| ^^^^^^^^^ | |
| test/asdf.rb:21:10: W: Lint/SplatKeywordArguments: Do not use splat keyword arguments as a single Hash. | |
| bar('b', **options) | |
| ^^^^^^^^^ | |
| test/asdf.rb:23:10: W: Lint/SplatKeywordArguments: Do not use splat keyword arguments as a single Hash. | |
| bar('b', **options, test: false) | |
| ^^^^^^^^^ | |
| test/asdf.rb:26:11: W: Lint/SplatKeywordArguments: Do not use splat keyword arguments as a single Hash. | |
| asdf('c', **options) | |
| ^^^^^^^^^ | |
| test/asdf.rb:28:11: W: Lint/SplatKeywordArguments: Do not use splat keyword arguments as a single Hash. | |
| asdf('c', **options, test: false) | |
| ^^^^^^^^^ | |
| 1 file inspected, 7 offenses detected |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| foo("a", {:test=>true}) | |
| /test/asdf.rb:16: warning: passing splat keyword arguments as a single Hash to `foo' | |
| foo("a", {:test=>true}) | |
| foo("a", {:test=>true}) | |
| /test/asdf.rb:18: warning: passing splat keyword arguments as a single Hash to `foo' | |
| foo("a", {:test=>false}) | |
| bar("b", **{:test=>true}) | |
| bar("b", **{:test=>true}) | |
| bar("b", **{:test=>true}) | |
| bar("b", **{:test=>false}) | |
| asdf("c", test: true) | |
| asdf("c", test: true) | |
| asdf("c", test: true) | |
| asdf("c", test: false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment