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

Enable InternalAffairs cop #93

Merged
merged 10 commits into from
Aug 31, 2022

Conversation

ydah
Copy link
Contributor

@ydah ydah commented Aug 18, 2022

This PR is a suggestion to enable effective cop when creating a cop for RuboCop.
It is useful to remind us to forget something without being too noisy.

Refs: https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/InternalAffairs

@ydah ydah force-pushed the enable_internal_affairs_cop branch from 3adda3f to 47214f6 Compare August 18, 2022 05:22
AllCops:
TargetRubyVersion: 2.5

GraphQL/ObjectDescription:
Enabled: false
Copy link
Owner

Choose a reason for hiding this comment

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

why should we disable this cop?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

# Offense count: 4
InternalAffairs/UndefinedConfig:
Exclude:
- 'lib/rubocop/cop/graphql/extract_input_type.rb'
- 'lib/rubocop/cop/graphql/extract_type.rb'
- 'lib/rubocop/cop/graphql/resolver_method_length.rb'

Disabled in the above response.
InternalAffairs/UndefinedConfig considers it a violation when an option not defined in config/default.yml is referenced as cop_config[Foo] etc.

Therefore, we require rubocop-graphql at

- rubocop-graphql

Then GraphQL/ObjectDescription will be enabled and the violation will be detected as follows
However, I don't think this is the cop that resolves the code under lib/rubocop/cop/graphql/*.

lib/rubocop/cop/graphql/argument_description.rb:21:13: C: GraphQL/ObjectDescription: Missing type description
      class ArgumentDescription < Base
            ^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/argument_name.rb:21:13: C: GraphQL/ObjectDescription: Missing type description
      class ArgumentName < Base
            ^^^^^^^^^^^^
lib/rubocop/cop/graphql/argument_uniqueness.rb:22:13: C: GraphQL/ObjectDescription: Missing type description
      class ArgumentUniqueness < Base
            ^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/extract_input_type.rb:6:13: C: GraphQL/ObjectDescription: Missing type description
      class ExtractInputType < Base
            ^^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/extract_type.rb:6:13: C: GraphQL/ObjectDescription: Missing type description
      class ExtractType < Base
            ^^^^^^^^^^^
lib/rubocop/cop/graphql/field_definitions.rb:47:13: C: GraphQL/ObjectDescription: Missing type description
      class FieldDefinitions < Base # rubocop:disable Metrics/ClassLength
            ^^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/field_description.rb:21:13: C: GraphQL/ObjectDescription: Missing type description
      class FieldDescription < Base
            ^^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/field_hash_key.rb:26:13: C: GraphQL/ObjectDescription: Missing type description
      class FieldHashKey < Base
            ^^^^^^^^^^^^
lib/rubocop/cop/graphql/field_method.rb:26:13: C: GraphQL/ObjectDescription: Missing type description
      class FieldMethod < Base
            ^^^^^^^^^^^
lib/rubocop/cop/graphql/field_name.rb:25:13: C: GraphQL/ObjectDescription: Missing type description
      class FieldName < Base
            ^^^^^^^^^
lib/rubocop/cop/graphql/field_uniqueness.rb:29:13: C: GraphQL/ObjectDescription: Missing type description
      class FieldUniqueness < Base
            ^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/legacy_dsl.rb:22:13: C: GraphQL/ObjectDescription: Missing type description
      class LegacyDsl < Base
            ^^^^^^^^^
lib/rubocop/cop/graphql/object_description.rb:23:13: C: GraphQL/ObjectDescription: Missing type description
      class ObjectDescription < Base
            ^^^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/ordered_arguments.rb:51:13: C: GraphQL/ObjectDescription: Missing type description
      class OrderedArguments < Base
            ^^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/ordered_fields.rb:33:13: C: GraphQL/ObjectDescription: Missing type description
      class OrderedFields < Base
            ^^^^^^^^^^^^^
lib/rubocop/cop/graphql/resolver_method_length.rb:10:13: C: GraphQL/ObjectDescription: Missing type description
      class ResolverMethodLength < Base
            ^^^^^^^^^^^^^^^^^^^^
lib/rubocop/cop/graphql/unused_argument.rb:63:13: C: GraphQL/ObjectDescription: Missing type description
      class UnusedArgument < Base
            ^^^^^^^^^^^^^^
lib/rubocop/graphql/argument.rb:5:11: C: GraphQL/ObjectDescription: Missing type description
    class Argument
          ^^^^^^^^
lib/rubocop/graphql/argument/block.rb:5:11: C: GraphQL/ObjectDescription: Missing type description
    class Argument
          ^^^^^^^^
lib/rubocop/graphql/argument/block.rb:6:13: C: GraphQL/ObjectDescription: Missing type description
      class Block
            ^^^^^
lib/rubocop/graphql/argument/kwargs.rb:5:11: C: GraphQL/ObjectDescription: Missing type description
    class Argument
          ^^^^^^^^
lib/rubocop/graphql/argument/kwargs.rb:6:13: C: GraphQL/ObjectDescription: Missing type description
      class Kwargs
            ^^^^^^
lib/rubocop/graphql/class.rb:5:11: C: GraphQL/ObjectDescription: Missing type description
    class Class
          ^^^^^
lib/rubocop/graphql/field.rb:5:11: C: GraphQL/ObjectDescription: Missing type description
    class Field
          ^^^^^
lib/rubocop/graphql/field/block.rb:5:11: C: GraphQL/ObjectDescription: Missing type description
    class Field
          ^^^^^
lib/rubocop/graphql/field/block.rb:6:13: C: GraphQL/ObjectDescription: Missing type description
      class Block
            ^^^^^
lib/rubocop/graphql/field/kwargs.rb:5:11: C: GraphQL/ObjectDescription: Missing type description
    class Field
          ^^^^^
lib/rubocop/graphql/field/kwargs.rb:6:13: C: GraphQL/ObjectDescription: Missing type description
      class Kwargs
            ^^^^^^
lib/rubocop/graphql/schema_member.rb:5:11: C: GraphQL/ObjectDescription: Missing type description
    class SchemaMember
          ^^^^^^^^^^^^
lib/rubocop/graphql/swap_range.rb:5:12: C: GraphQL/ObjectDescription: Missing type description
    module SwapRange
           ^^^^^^^^^

66 files inspected, 30 offenses detected

@@ -93,6 +93,7 @@ def field_name(node)
"`#{first_argument.value}`"
end

# @!method argument_declarations(node)
Copy link
Owner

Choose a reason for hiding this comment

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

what does it do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an autocorrected by InternalAffairs/NodeMatcherDirective.

https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/InternalAffairs/NodeMatcherDirective
Checks that node matcher definitions are tagged with a YARD @!method directive so that editors are able to find the dynamically defined method.

@DmitryTsepelev
Copy link
Owner

Hi @ydah, thanks for the PR! Could you please explain me a couple of things above? 🙂

ydah added 8 commits August 19, 2022 07:32
bundle exec rubocop -a --only InternalAffairs/CopDescription
bundle exec rubocop -a --only InternalAffairs/MethodNameEqual
bundle exec rubocop -a --only InternalAffairs/NodeMatcherDirective
bundle exec rubocop -a --only InternalAffairs/NodeTypePredicate
bundle exec rubocop -a --only InternalAffairs/RedundantDescribedClassAsSubject
bundle exec rubocop -a --only InternalAffairs/RedundantLetRuboCopConfigNew
@ydah ydah requested a review from DmitryTsepelev August 18, 2022 22:46
@DmitryTsepelev
Copy link
Owner

Could you please also take a look at rubocop failure? 🙂

```
spec/rubocop/cop/graphql/argument_description_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/argument_description_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/argument_name_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/argument_name_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/argument_uniqueness_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/argument_uniqueness_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/extract_input_type_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/extract_type_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/field_definitions_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/field_description_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/field_description_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/field_hash_key_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/field_hash_key_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/field_method_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/field_method_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/field_name_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/field_name_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/field_uniqueness_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/field_uniqueness_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/legacy_dsl_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/legacy_dsl_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/object_description_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/object_description_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/ordered_arguments_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/ordered_arguments_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/ordered_fields_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/ordered_fields_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
spec/rubocop/cop/graphql/resolver_method_length_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/unused_argument_spec.rb:4:1: C: [Corrected] Layout/EmptyLinesAroundBlockBody: Extra empty line detected at block body beginning.
spec/rubocop/cop/graphql/unused_argument_spec.rb:5:1: C: [Corrected] Layout/EmptyLines: Extra blank line detected.
```
@ydah ydah force-pushed the enable_internal_affairs_cop branch from f69d0c4 to 2d26c96 Compare August 20, 2022 12:31
@ydah ydah force-pushed the enable_internal_affairs_cop branch from d1a34c6 to 78d8682 Compare August 20, 2022 12:35
@ydah
Copy link
Contributor Author

ydah commented Aug 20, 2022

Ops, sorry. I updated this PR.

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 🙂

@DmitryTsepelev DmitryTsepelev merged commit 106d772 into DmitryTsepelev:master Aug 31, 2022
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.

2 participants