Skip to content

Commit

Permalink
Suppress RuboCop offense (#172)
Browse files Browse the repository at this point in the history
This PR suppresses the following `InternalAffairs/OnSendWithoutOnCSend and `InternalAffairs/NodeTypeMultiplePredicates` offenses:

```console
lib/rubocop/cop/graphql/unnecessary_field_camelize.rb:27:9:
C: InternalAffairs/OnSendWithoutOnCSend: Cop defines on_send but not on_csend.
        def on_send(node) ...
        ^^^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/unused_argument.rb:106:13:
C: [Correctable] InternalAffairs/NodeTypeMultiplePredicates: Use arg.type?(:kwarg, :kwoptarg) instead of checking for multiple node types.
            arg.kwarg_type? || arg.kwoptarg_type?
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```

`InternalAffairs/OnSendWithoutOnCSend` is disabled in `.rubocop.yml` as it doesn't seem useful for `rubocop-graphql`,
which primarily focuses on DSLs that do not assume a receiver.

`InternalAffairs/NodeTypeMultiplePredicates` is auto-corrected to enforce style consistency.
  • Loading branch information
koic authored Feb 16, 2025
1 parent 0f21c74 commit 8b613cf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ GraphQL/MaxDepthSchema:
- lib/rubocop/cop/graphql/max_complexity_schema.rb
- lib/rubocop/cop/graphql/max_depth_schema.rb

InternalAffairs/OnSendWithoutOnCSend:
Enabled: false

# FIXME: Workaround for a false positive caused by this cop when using `bundle exec rake`.
InternalAffairs/UndefinedConfig:
Enabled: false
8 changes: 4 additions & 4 deletions lib/rubocop/cop/graphql/unused_argument.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def find_resolve_method_node(node)

def find_unresolved_args(method_node, declared_arg_nodes)
resolve_method_kwargs = method_node.arguments.select do |arg|
arg.kwarg_type? || arg.kwoptarg_type?
arg.type?(:kwarg, :kwoptarg)
end
resolve_method_kwargs_names = resolve_method_kwargs.map do |node|
node.node_parts[0]
Expand All @@ -116,7 +116,7 @@ def find_unresolved_args(method_node, declared_arg_nodes)

def ignore_arguments_type?(resolve_method_node)
resolve_method_node.arguments.any? do |arg|
arg.arg_type? || arg.kwrestarg_type? || arg.forward_arg_type?
arg.type?(:arg, :kwrestarg, :forward_arg)
end
end

Expand Down Expand Up @@ -172,11 +172,11 @@ def scoped_node?(node)
end

def scope_changing_syntax?(node)
node.def_type? || node.defs_type? || node.class_type? || node.module_type?
node.type?(:def, :defs, :class, :module)
end

def block_or_lambda?(node)
node.block_type? || node.lambda_type?
node.type?(:block, :lambda)
end

# @!method argument_declaration?(node)
Expand Down
2 changes: 1 addition & 1 deletion lib/rubocop/graphql/heredoc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module RuboCop
module GraphQL
module Heredoc
def heredoc?(node)
(node.str_type? || node.dstr_type?) && node.heredoc?
node.type?(:str, :dstr) && node.heredoc?
end

def range_including_heredoc(node)
Expand Down

0 comments on commit 8b613cf

Please sign in to comment.