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

Move rubocop:disable comments out of documentation #299

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

sambostock
Copy link
Contributor

@sambostock sambostock commented Jun 20, 2024

When rubocop:disable is used immediately above a method or module declaration, it becomes part of the documentation.

e.g. Node#value_used?

image

Instead, if we inline it with the declaration itself, it is not included in the documentation. As a side benefit, RuboCop attaches it to that declaration only, removing the need to rubocop:enable afterwards.

However, YARD applies it as documentation to whatever immediately follows, so if the next declaration is public, we must explicitly document it, so YARD properly ignores the rubocop:disable comment.

When `rubocop:disable` is used immediately above a method or module
declaration, it becomes part of the documentation.

Instead, if we inline it with the declaration itself, it is not included
in the documentation. As a side benefit, RuboCop attaches it to that
declaration only, removing the need to `rubocop:enable` afterwards.

However, YARD applies it as documentation to whatever immediately
follows, so if the next declaration is public, we must explicitly
document it, so YARD properly ignores the `rubocop:disable` comment.
# rubocop:disable Metrics/ClassLength
class SequenceSubcompiler < Subcompiler
class SequenceSubcompiler < Subcompiler # rubocop:disable Metrics/ClassLength
# Shift of 1 from standard Ruby indices
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Inferred from a comment later in this file.

Comment on lines +29 to +31
# Yields for each branch of the given union, forbidding unification of
# bindings which only appear in a subset of the union.
def union_bind(enum) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not familiar with this section of the code base and what this method is actually meant to do, so I'm not sure this comment is accurate.

@marcandre marcandre merged commit d26a5e9 into rubocop:master Jun 20, 2024
19 checks passed
@marcandre
Copy link
Contributor

Thank you.

@sambostock sambostock deleted the rubocop-disable-in-docs branch June 20, 2024 13:09
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