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.e.g.
Node#value_used?
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.