DmitryTsepelev / rubocop-graphql

Rubocop extension for enforcing graphql-ruby best practices
MIT License
226 stars 50 forks source link

Optimize `OrderedArguments` and `FieldDefinitions` cops #157

Closed fatkodima closed 6 months ago

fatkodima commented 6 months ago

We currently have a very large file where this gem's cops stuck and never finish. The reasons are that lib/rubocop/graphql/sorbet.rb uses O(n^2) loop and lib/rubocop/cop/graphql/ordered_arguments.rb performs a costly traversing of the descendants tree twice, where only one would suffice.

After these changes, now rubocop finishes in 17 seconds for that file.

fatkodima commented 6 months ago

Made rubocop happy 😄