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

Suggest to "Open the singleton class with class << self" when Style/ModuleFunction is set to forbidden #11045

Merged

Conversation

RDeckard
Copy link
Contributor

@RDeckard RDeckard commented Oct 4, 2022

Context:

Style/ModuleFunction:
  EnforcedStyle: forbidden

When extend self or module_function is used in this context ⬆️, the cop message might suggest to "Open the singleton class with class << self instead.".
WDYT?


Before submitting the PR make sure the following are checked:

  • The PR relates to only one subject with a clear title and description in grammatically correct, complete sentences.
  • Wrote good commit messages.
  • Commit message starts with [Fix #issue-number] (if the related issue exists).
  • Feature branch is up-to-date with master (if not - rebase it).
  • Squashed related commits together.
  • Added tests.
  • Ran bundle exec rake default. It executes all tests and runs RuboCop on its own code.
  • Added an entry (file) to the changelog folder named {change_type}_{change_description}.md if the new code introduces user-observable changes. See changelog entry format for details.

@RDeckard RDeckard force-pushed the cop/style/module_function-forbidden_msg-update branch 2 times, most recently from 631d009 to 5af6d16 Compare October 4, 2022 15:54
@RDeckard RDeckard marked this pull request as ready for review October 4, 2022 16:16
@RDeckard RDeckard force-pushed the cop/style/module_function-forbidden_msg-update branch from 5af6d16 to e6a5da5 Compare October 10, 2022 08:31
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 20, 2022

We rarely use messages that are multi-sentence, so I think it would probably be better to improve the cop documentation instead. I see we have no suggestions for the forbidden style at all there and in general the documentation is pretty basic to begin with.

@RDeckard RDeckard force-pushed the cop/style/module_function-forbidden_msg-update branch from f3ba1f8 to a063967 Compare October 25, 2022 12:44
@RDeckard
Copy link
Contributor Author

RDeckard commented Oct 25, 2022

I think it would probably be better to improve the cop documentation instead.

Good idea 👍, I've reverted the changes and updated the documentation with this suggestion + trying to make it a little more accurate about the extend self + private exception.

@RDeckard RDeckard force-pushed the cop/style/module_function-forbidden_msg-update branch from a063967 to c094158 Compare October 25, 2022 12:49
…n the singleton class with `class << self` instead.".
… to "Open the singleton class with `class << self` instead."."

This reverts commit e6a5da52e0e57158f6902e956c5675ba8198268f.
@RDeckard RDeckard force-pushed the cop/style/module_function-forbidden_msg-update branch 2 times, most recently from 8df3a58 to de93416 Compare October 25, 2022 12:55
@bbatsov bbatsov merged commit 72f8c69 into rubocop:master Oct 30, 2022
@bbatsov
Copy link
Collaborator

bbatsov commented Oct 30, 2022

Thanks!

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.

None yet

2 participants