KEMBAR78
Enhance `Naming/MethodName` cop to detect offenses within `define_method` calls by viralpraxis · Pull Request #14331 · rubocop/rubocop · GitHub
Skip to content

Conversation

@viralpraxis
Copy link
Contributor

ref: #14325 (comment)

This patch enhances Naming/MethodName to detect these offenses:

define_method(:fooBar) {} # offense if style is `snake_case`

define_method(:foo_bar) {} # offense if style is `camelCase`

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.
  • 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.

@bbatsov
Copy link
Collaborator

bbatsov commented Jun 26, 2025

Please, update the cop examples in the docs as well. Apart from this your changes look good to me.

…hod` calls

ref: rubocop#14325 (comment)

This patch enhances `Naming/MethodName` to detect these offenses:

```ruby
define_method(:fooBar) {} # offense if style is `snake_case`

define_method(:foo_bar) {} # offense if style is `camelCase`
```
@viralpraxis viralpraxis force-pushed the enhance-naming-method-name-cop-to-detect-offenses-within-define-method-calls branch from 51370b0 to 04cc28a Compare June 26, 2025 08:17
@viralpraxis
Copy link
Contributor Author

Please, update the cop examples in the docs as well. Apart from this your changes look good to me.

Done!

@viralpraxis
Copy link
Contributor Author

CI failure is unrelated and seems to be already fixed here: ruby/rubygems@9a9d0e4

@bbatsov bbatsov merged commit e4dd6a3 into rubocop:master Jun 26, 2025
22 of 23 checks passed
@bbatsov
Copy link
Collaborator

bbatsov commented Jun 26, 2025

Thanks!

@viralpraxis viralpraxis deleted the enhance-naming-method-name-cop-to-detect-offenses-within-define-method-calls branch June 26, 2025 10:27
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