Skip to content
New issue

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

GraphQL/OrderedFields crashes during autocorrect #63

Closed
ojab opened this issue Dec 31, 2021 · 1 comment · Fixed by #86
Closed

GraphQL/OrderedFields crashes during autocorrect #63

ojab opened this issue Dec 31, 2021 · 1 comment · Fixed by #86
Labels
bug Something isn't working

Comments

@ojab
Copy link

ojab commented Dec 31, 2021

class SomeType < Types::BaseObject
  field :id, Integer
  field :some_field, Integer
  field :field_too, Integer
  field :field, Integer
end

leads to

$ bundle exec rubocop --only GraphQL/OrderedFields -ad app/graphql/types/some_type.rb 
…
An error occurred while GraphQL/OrderedFields cop was inspecting /…/app/graphql/types/some_type.rb:1:0.
Parser::Source::TreeRewriter detected clobbering
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter.rb:427:in `trigger_policy'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter.rb:414:in `enforce_policy'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:225:in `call'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:225:in `call_enforcer_for_merge'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:216:in `merge'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:104:in `do_combine'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:117:in `place_in_hierarchy'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:131:in `block in combine_children'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:130:in `each'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:130:in `inject'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:130:in `combine_children'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:221:in `merge'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:104:in `do_combine'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter/action.rb:30:in `combine'
…/gems/parser-3.0.3.2/lib/parser/source/tree_rewriter.rb:143:in `merge!'
…/gems/rubocop-1.24.0/lib/rubocop/cop/base.rb:291:in `apply_correction'
…/gems/rubocop-1.24.0/lib/rubocop/cop/base.rb:375:in `attempt_correction'
…/gems/rubocop-1.24.0/lib/rubocop/cop/base.rb:356:in `use_corrector'
…/gems/rubocop-1.24.0/lib/rubocop/cop/base.rb:350:in `correct'
…/gems/rubocop-1.24.0/lib/rubocop/cop/base.rb:127:in `add_offense'
…/gems/rubocop-graphql-0.12.0/lib/rubocop/cop/graphql/ordered_fields.rb:60:in `register_offense'
…/gems/rubocop-graphql-0.12.0/lib/rubocop/cop/graphql/ordered_fields.rb:47:in `block in on_class'
…/gems/rubocop-graphql-0.12.0/lib/rubocop/cop/graphql/ordered_fields.rb:100:in `block in field_declarations'
…/gems/rubocop-ast-1.15.1/lib/rubocop/ast/node/mixin/descendence.rb:106:in `block in visit_descendants'
…

on

$ bundle exec rubocop -V
1.24.0 (using Parser 3.0.3.2, rubocop-ast 1.15.1, running on ruby 3.1.0 x86_64-linux)

with rubocop-graphql-0.12.0 (not sure if it's rubocop or rubocop-graphql but that it's not showing in rubocop -V).

@DmitryTsepelev DmitryTsepelev added the bug Something isn't working label Jan 11, 2022
@DmitryTsepelev
Copy link
Owner

I could reproduce the issue locally but didn't come with the fix yet. Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants