Skip to content

Commit

Permalink
Add rule about not extending Data.define
Browse files Browse the repository at this point in the history
See also:
* [PR adding new cop for this rule](rubocop/rubocop#11728)
* [Original issue](rubocop/rubocop#11696)
  • Loading branch information
Karol Topolski committed Mar 26, 2023
1 parent 7e54062 commit 1f15b25
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5842,6 +5842,21 @@ config

This is simpler and more efficient.

=== Don't Extend `Data.define` [[no-extend-data-define]]

Don't extend an instance initialized by `Data.define`.
Extending it introduces a superfluous class level and may also introduce weird errors if the file is required multiple times.

[source,ruby]
----
# bad
class Person < Data.define(:first_name, :last_name)
end
# good
Person = Data.define(:first_name, :last_name)
----

== Tools

Here are some tools to help you automatically check Ruby code against this guide.
Expand Down

0 comments on commit 1f15b25

Please sign in to comment.