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

Add option to exclude methods for Style/DocumentationMethod cop #11504

Closed
blackst0ne opened this issue Jan 26, 2023 · 1 comment · Fixed by #11506
Closed

Add option to exclude methods for Style/DocumentationMethod cop #11504

blackst0ne opened this issue Jan 26, 2023 · 1 comment · Fixed by #11506

Comments

@blackst0ne
Copy link

blackst0ne commented Jan 26, 2023

Is your feature request related to a problem? Please describe.

The Style/DocumentationMethod checks for all the public methods including initialize.
The constructor doesn't have to have a documentation comment.

Describe the solution you'd like

Add an option for the cop to exclude method names. E.g.

Style/DocumentationMethod:
  Enabled: true
  Include:
    - 'app/policies/**/*.rb'
  ExcludedMethods:
  - 'initialize'
  - 'foo'
  - 'bar'

Describe alternatives you've considered

An alternative is to disable the cop by the rubocop:disable comment around wanted methods.

@koic
Copy link
Member

koic commented Jan 26, 2023

Looks reasonable to me. I've opened #11506.

koic added a commit to koic/rubocop that referenced this issue Jan 26, 2023
…Method`

Fixes rubocop#11504.

This PR makes to allow `initialize` method in `Style/DocumentationMethod`
because `initialize` is a special method called from `new`.
In some languages they are called constructor to distinguish it from method.

So it would be different from the following intent that this cop wants to detect.

> Checks for missing documentation comment for public methods.
> It can optionally be configured to also require documentation for
> non-public methods.
bbatsov pushed a commit that referenced this issue Jan 26, 2023
Fixes #11504.

This PR makes to allow `initialize` method in `Style/DocumentationMethod`
because `initialize` is a special method called from `new`.
In some languages they are called constructor to distinguish it from method.

So it would be different from the following intent that this cop wants to detect.

> Checks for missing documentation comment for public methods.
> It can optionally be configured to also require documentation for
> non-public methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants