-
Notifications
You must be signed in to change notification settings - Fork 49
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/ObjectDescription Reports False Positives #145
Comments
Hey @jblacker! Yeah, we can add it to the exclude if we know the exact file. I guess files you mentioned can be literally anywhere, so it makes sense to just check for the base class. So my proposal is:
|
@DmitryTsepelev Originally I was thinking the same, but I did a deep dive into some of the base classes of the Whereas if we go down the route using exclusion rather than inclusion then we run the risk of this cop being more fragile and potentially breaking upon "non-breaking changes" to the main repo. This module that provides the We can then update the cop to only be applied to classes that include this mixin and it should be far more accurate moving forward. |
The only problem is that we do not have a runtime in cops, it's just an AST, so we won't be able to check if |
Ah, I didn't realize that Rubocop only works on AST (I'm relatively new to the Ruby world). I'm guessing it's not really feasible to read all of the extension / include / extend and recurse through the files/gems to determine if it's included or not. |
Yeah, we can only rely on conventions (i.e., if we make agreement to include everything explicitly or inherit from a specific class) |
I also see this issue happening in our code base, actually it's even worse:
Example: class Mutations::ApplyPromotionToCurrentOrder < GraphQL::Schema::Resolver
description '...'
class OrderNotFound < Errors::PreconditionFailed; end # rubocop:todo GraphQL/ObjectDescription
class PaymentAlreadyExists < Errors::PreconditionFailed; end # rubocop:todo GraphQL/ObjectDescription
...
end |
This issue is related to #42, but it doesn't seem that issue was properly resolved. As mentioned in that issue this cop triggers for any class in the graphql folder, but this should not be how it functions. Due to this it also triggers on implementations of
GraphQL::Analysis::AST::*
classes as well asGraphQL::Schema::Validator
implementations. However, neither of these classes implement thedescription
method that RuboCop is saying to add here. Sure it's easy to add anExcludes
to the RuboCop configuration, but this seems like a bug that should be resolved.The text was updated successfully, but these errors were encountered: