Closed lasseebert closed 1 month ago
Hey, thanks for reporting this and sorry for the trouble. I added a test case with the same definition in your example, but (unfortunately...) it passed: 5dcdb597c
I see there is another cop reporting an error in your example -- I wonder if these two are somehow conflicting. Could you share the source for that cop, or try disabling it locally to see if this example still fails?
When I clone this repo and try to run the tests, I seem to always get zero rubocop errors (even for the tests that asserts that there should be rubocop errors).
I tried to debug and figured out that the new fixture probably should be added to the config, right?
( I didn't solve the always-zero-errors thing above, but that is problably something in my setup)
Btw, the other cop reporting an error is a cop that sorts the fields of a graphql type alphabetically. I get the same error if they are sorted correctly.
🤦 Derp, thanks for debugging that. I worked up a fix in #5107 (and improved my testing helpers to make sure I don't overlook that configuration issue next time)!
Thanks for the fix again! :tada:
I tested on master
and it fixed this problem.
This revealed another problem though. Will open another issue for that :grin:
Describe the bug
Thanks for the fix for https://github.com/rmosolgo/graphql-ruby/issues/5097. I tried updating to the new version and bumped into another issue.
This is the minimal type I can replicate the bug with. It seems to only fail on array return types.
This fails with this. See full stack trace at the bottom.
Versions
graphql
version: 2.3.16rails
(or other framework): 7.2.1GraphQL schema
Steps to reproduce
Expected behavior
No exceptions
Actual behavior
An exception
Click to view exception backtrace
``` $ bin/rubocop app/graphql/types/foo_type.rb -d For /home/me/code/myapp/apps/api: configuration from /home/me/code/myapp/apps/api/.rubocop.yml Inheriting configuration from /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/test-prof-1.4.2/config/rubocop-rspec.yml Inheriting configuration from /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/syntax_tree-6.1.1/config/rubocop.yml Inheriting configuration from /home/me/code/myapp/apps/api/.rubocop_backlog.yml Inheriting configuration from /home/me/code/myapp/apps/api/.rubocop_todo.yml .rubocop.yml: Metrics/PerceivedComplexity:Exclude overrides the same parameter in .rubocop_backlog.yml Inspecting 1 file Scanning /home/me/code/myapp/apps/api/app/graphql/types/foo_type.rb Invariant: Something went wrong in GraphQL-Ruby, couldn't find surrounding class definition for field ((send nil :field (sym :bar) (array (const nil :String)) (hash (pair (sym :null) (false))))). Please report this error on GitHub. /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/graphql-2.3.16/lib/graphql/rubocop/graphql/field_type_in_block.rb:119:in `determine_field_indent' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/graphql-2.3.16/lib/graphql/rubocop/graphql/field_type_in_block.rb:65:in `block (2 levels) in on_send' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/base.rb:416:in `correct' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/base.rb:210:in `add_offense' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/graphql-2.3.16/lib/graphql/rubocop/graphql/field_type_in_block.rb:63:in `block in on_send' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/graphql-2.3.16/lib/graphql/rubocop/graphql/field_type_in_block.rb:33:in `field_config_with_inline_type' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/graphql-2.3.16/lib/graphql/rubocop/graphql/field_type_in_block.rb:57:in `on_send' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:107:in `public_send' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:107:in `block (2 levels) in trigger_responding_cops' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:171:in `with_cop_error_handling' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:106:in `block in trigger_responding_cops' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:105:in `each' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:105:in `trigger_responding_cops' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:69:in `on_send' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.3/lib/rubocop/ast/traversal.rb:154:in `on_block' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:71:in `on_block' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.3/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.3/lib/rubocop/ast/traversal.rb:137:in `each' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.3/lib/rubocop/ast/traversal.rb:137:in `on_dstr' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:71:in `on_begin' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.3/lib/rubocop/ast/traversal.rb:154:in `on_class' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:71:in `on_class' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-ast-1.32.3/lib/rubocop/ast/traversal.rb:20:in `walk' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/commissioner.rb:87:in `investigate' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/team.rb:168:in `investigate_partial' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cop/team.rb:102:in `investigate' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:349:in `block in inspect_file' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:348:in `each' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:348:in `flat_map' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:348:in `inspect_file' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:291:in `block in do_inspection_loop' /home/me/.asdf/installs/ruby/3.3.5/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:325:in `block in iterate_until_no_changes'