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

Implement UnusedArgument cop #61

Merged
merged 10 commits into from
Dec 30, 2021

Conversation

aishek
Copy link
Contributor

@aishek aishek commented Dec 23, 2021

First of all, I've implemented autocorrection, and I am not sure if it is better than just add errors to arguments.

And the second thing is the cop ignores the case when there is no resolve method at all.

What do you think?

Resolves #53

Copy link
Owner

@DmitryTsepelev DmitryTsepelev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start! Please check out my comments below and let's make CI pass

lib/rubocop/cop/graphql/unused_argument.rb Outdated Show resolved Hide resolved
lib/rubocop/cop/graphql/unused_argument.rb Show resolved Hide resolved
lib/rubocop/cop/graphql/unused_argument.rb Outdated Show resolved Hide resolved
lib/rubocop/cop/graphql/unused_argument.rb Outdated Show resolved Hide resolved
aishek and others added 5 commits December 29, 2021 00:13
Co-authored-by: Dmitry Tsepelev <dmitry.a.tsepelev@gmail.com>
Co-authored-by: Dmitry Tsepelev <dmitry.a.tsepelev@gmail.com>
Co-authored-by: Dmitry Tsepelev <dmitry.a.tsepelev@gmail.com>
Co-authored-by: Dmitry Tsepelev <dmitry.a.tsepelev@gmail.com>
@aishek
Copy link
Contributor Author

aishek commented Dec 28, 2021

Thanks for the comments! I've applied them, and also made the code backward compatible.

I am not sure if the following method if reliable enough:

def method_name(node)
  node.loc.keyword.end.resize(node.method_name.to_s.size + 1)
end

Util.args_begin won't work for me somehow.

@DmitryTsepelev
Copy link
Owner

Specs are still failing (because of my stupid suggestion mostly) and we have a number of rubocop offences 🙂

@aishek
Copy link
Contributor Author

aishek commented Dec 29, 2021

Ok, I fixed it all 🤞

Copy link
Owner

@DmitryTsepelev DmitryTsepelev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@DmitryTsepelev DmitryTsepelev merged commit f82652b into DmitryTsepelev:master Dec 30, 2021
@jgrau
Copy link

jgrau commented Jan 3, 2022

Was the loads: argument considered? I have this chunk of code in a mutation:

...
    argument :booking_id, String, loads: Types::BookingType

    def resolve(booking:)
      ...
    end
...

but that complains that it wants booking_id to be a keyword argument in the resolve method.

:)

@aishek
Copy link
Contributor Author

aishek commented Jan 3, 2022

Was the loads: argument considered?

No, it was not. I will fix it, thanks!

@aishek
Copy link
Contributor Author

aishek commented Jan 3, 2022

I've created the fix #65

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New cop: UnusedArgument
3 participants