I would expect the following to not cause an error:
def define_equality define_method(:==) { |other| other.is_a?(self.class) && hash == other.hash } endActual behavior
Here's the output I see:
demo:16:17: C: Naming/MethodName: Use snake_case for method names. (https://rubystyle.guide#snake-case-symbols-methods-vars)
define_method(:==) { |other| other.is_a?(self.class) && hash == other.hash }
^^^^
The problem is that RuboCop doesn't like the symbolized version equality (:==
). ...but I'm guessing this to be an issue with any method using special characters as an argument to define_method
.
Use the following code snippet with the latest release of RuboCop to recreate:
def define_equality define_method(:==) { |other| other.is_a?(self.class) && hash == other.hash } endRuboCop version
1.78.0 (using Parser 3.3.8.0, Prism 1.4.0, rubocop-ast 1.45.1, analyzing as Ruby 3.4, running on ruby 3.4.4) [arm64-darwin24.5.0]
- rubocop-capybara 2.22.1
- rubocop-disable_syntax 0.2.0
- rubocop-packaging 0.6.0
- rubocop-performance 1.25.0
- rubocop-thread_safety 0.7.3
- rubocop-rake 0.7.1
- rubocop-rspec 3.6.0
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4