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
coerce_input ->(value, _ctx) do begin value.nil? ? nil : JSON.parse(value) rescue JSON::ParserError raise GraphQL::CoercionError, "cannot coerce `#{value.inspect}` to Hash value" end end
is valid code (when stabby syntax is preferred in config).
After format it looks like this
coerce_input ->(value, _ctx) do value.nil? ? nil : JSON.parse(value) rescue JSON::ParserError raise GraphQL::CoercionError, "cannot coerce `#{value.inspect}` to Hash value" end
which is invalid as heck.
Ruby's major GraphQL implementation often uses lambdas in arguments, we ended up sticking a begin/rescue/end block in one (because it works).
When it's separated by braces, a la
coerce_method ->(value, _ctx) { begin value.nil? ? nil : JSON.parse(value) rescue JSON::ParserError raise GraphQL::CoercionError, "cannot coerce `#{value.inspect}` to Hash value" end }
It works fine. Or if it was forced to be
coerce_input lambda(value, _ctx) do value.nil? ? nil : JSON.parse(value) rescue JSON::ParseError raise GraphQL::CoercionError, "cannot coerce `#{value.inspect}` to Hash value" end
Basically it tries to handle the stabby syntax in the same way that's allowed by the lambda syntax and ruby doesn't handle them the same way at all.
This exists in the same format whether it's being used as an argument or assigning the lambda to a variable.
0.58.2 (using Parser 2.5.1.2, running on ruby 2.5.1 x86_64-linux)
The text was updated successfully, but these errors were encountered:
Good catch. Will have a look at this.
Sorry, something went wrong.
[Fix rubocop#6192] Make Style/RedundantBegin cop aware of stabby lambdas
227eb20
Stabby lambda blocks don't support the implicit rescue syntax. This change makes the cop ignore such cases.
7301802
Drenmi
No branches or pull requests
Expected behavior
is valid code (when stabby syntax is preferred in config).
Actual behavior
After format it looks like this
which is invalid as heck.
Additional Info
Ruby's major GraphQL implementation often uses lambdas in arguments, we ended up sticking a begin/rescue/end block in one (because it works).
When it's separated by braces, a la
It works fine. Or if it was forced to be
Basically it tries to handle the stabby syntax in the same way that's allowed by the lambda syntax and ruby doesn't handle them the same way at all.
This exists in the same format whether it's being used as an argument or assigning the lambda to a variable.
RuboCop version
0.58.2 (using Parser 2.5.1.2, running on ruby 2.5.1 x86_64-linux)
The text was updated successfully, but these errors were encountered: