You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running Rubocop, the GraphQL/FieldTypeInBlock cop fails on some files in our code base.
It seems to be only on GraphQL types that inherit from other types and adds a single field.
Versions
Rubocop output:
Mention the following information in the issue report:
1.66.1 (using Parser 3.3.5.0, rubocop-ast 1.32.3, running on ruby 3.3.4) +server [x86_64-linux]
Have the above class and run rubocop. Dependent types doesn't need to exist for the error to come.
Expected behavior
It should not fail and possibly correct the code.
Actual behavior
When running rubocop this is shown:
$ bin/rubocop path/to/admin/foo_type.rb
Inspecting 1 file
.
1 file inspected, no offenses detected
An error occurred while GraphQL/FieldTypeInBlock cop was inspecting /path/to/admin/foo_type.rb:2:2.
To see the complete backtrace run rubocop -d.
1 error occurred:
An error occurred while GraphQL/FieldTypeInBlock cop was inspecting /path/to/admin/foo_type.rb:2:2.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues
Mention the following information in the issue report:
1.66.1 (using Parser 3.3.5.0, rubocop-ast 1.32.3, running on ruby 3.3.4) +server [x86_64-linux]
When running with backtrace:
Click to view exception backtrace
$ bin/rubocop path/to/admin/foo_type.rb -d
For /my/app: configuration from /my/app/.rubocop.yml
Inheriting configuration from /home/me/.asdf/installs/ruby/3.3.4/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.4/lib/ruby/gems/3.3.0/gems/syntax_tree-6.1.1/config/rubocop.yml
Inheriting configuration from /my/app/.rubocop_backlog.yml
Inheriting configuration from /my/app/.rubocop_todo.yml
.rubocop.yml: Metrics/PerceivedComplexity:Exclude overrides the same parameter in .rubocop_backlog.yml
Inspecting 1 file
Scanning /my/app/admin/foo_type.rb
undefined method `source' for nil
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/graphql-2.3.15/lib/graphql/rubocop/graphql/field_type_in_block.rb:114:in `determine_field_indent'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/graphql-2.3.15/lib/graphql/rubocop/graphql/field_type_in_block.rb:65:in `block (2 levels) in on_send'
/home/me/.asdf/installs/ruby/3.3.4/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.4/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.4/lib/ruby/gems/3.3.0/gems/graphql-2.3.15/lib/graphql/rubocop/graphql/field_type_in_block.rb:63:in `block in on_send'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/graphql-2.3.15/lib/graphql/rubocop/graphql/field_type_in_block.rb:33:in `field_config_with_inline_type'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/graphql-2.3.15/lib/graphql/rubocop/graphql/field_type_in_block.rb:57:in `on_send'
/home/me/.asdf/installs/ruby/3.3.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/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.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:325:in `block in iterate_until_no_changes'
<internal:kernel>:187:in `loop'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:318:in `iterate_until_no_changes'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:287:in `do_inspection_loop'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:168:in `block in file_offenses'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:193:in `file_offense_cache'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:167:in `file_offenses'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:158:in `process_file'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:139:in `block in each_inspected_file'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:138:in `each'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:138:in `reduce'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:138:in `each_inspected_file'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:124:in `inspect_files'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/runner.rb:77:in `run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli/command.rb:11:in `run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli/environment.rb:18:in `run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli.rb:122:in `run_command'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli.rb:129:in `execute_runners'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli.rb:51:in `block in run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli.rb:81:in `profile_if_needed'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/cli.rb:43:in `run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/server_command/exec.rb:22:in `run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/server_command/base.rb:24:in `block in run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/server_command/base.rb:23:in `chdir'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/server_command/base.rb:23:in `run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/socket_reader.rb:33:in `block in read!'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/helper.rb:26:in `redirect'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/socket_reader.rb:28:in `read!'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/core.rb:90:in `read_socket'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/core.rb:65:in `block in process_input'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/cache.rb:150:in `write_pid_file'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/core.rb:64:in `process_input'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/core.rb:53:in `block in detach_server'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/core.rb:46:in `fork'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/core.rb:46:in `detach_server'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/core.rb:38:in `start'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/client_command/start.rb:42:in `block in run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/cache.rb:137:in `acquire_lock'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/client_command/start.rb:29:in `run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/client_command/exec.rb:40:in `ensure_server!'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/lib/rubocop/server/client_command/exec.rb:19:in `run'
/home/me/.asdf/installs/ruby/3.3.4/lib/ruby/gems/3.3.0/gems/rubocop-1.66.1/exe/rubocop:12:in `<top (required)>'
/my/app/bin/rubocop:31:in `load'
/my/app/bin/rubocop:31:in `<main>'
.
1 file inspected, no offenses detected
An error occurred while GraphQL/FieldTypeInBlock cop was inspecting /path/to/admin/foo_type.rb:2:2.
To see the complete backtrace run rubocop -d.
1 error occurred:
An error occurred while GraphQL/FieldTypeInBlock cop was inspecting /path/to/admin/foo_type.rb:2:2.
Errors are usually caused by RuboCop bugs.
Please, report your problems to RuboCop's issue tracker.
https://github.com/rubocop/rubocop/issues
Mention the following information in the issue report:
1.66.1 (using Parser 3.3.5.0, rubocop-ast 1.32.3, running on ruby 3.3.4) +server [x86_64-linux]
The text was updated successfully, but these errors were encountered:
Thanks for the detailed report! It looks like RuboCop's AST structure is different for classes which have only a single expression in them. I updated it in #5098!
Describe the bug
When running Rubocop, the
GraphQL/FieldTypeInBlock
cop fails on some files in our code base.It seems to be only on GraphQL types that inherit from other types and adds a single field.
Versions
Rubocop output:
graphql
version: 2.3.15rails
: 7.2.1GraphQL schema
Steps to reproduce
Have the above class and run rubocop. Dependent types doesn't need to exist for the error to come.
Expected behavior
It should not fail and possibly correct the code.
Actual behavior
When running rubocop this is shown:
When running with backtrace:
Click to view exception backtrace
The text was updated successfully, but these errors were encountered: