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

Struct.new do and Metrics/BlockLength vs Metrics/ClassLength #8102

Closed
marcandre opened this issue Jun 6, 2020 · 0 comments · Fixed by #8122
Closed

Struct.new do and Metrics/BlockLength vs Metrics/ClassLength #8102

marcandre opened this issue Jun 6, 2020 · 0 comments · Fixed by #8122

Comments

@marcandre
Copy link
Contributor

marcandre commented Jun 6, 2020

# This style is used by many people
MyClass < Struct.new(:foo, :bar)
  # ...
end

# This style is mostly equivalent and is the "official" style:
MyClass = Struct.new(:foo, :bar) do
  # ...
end

Both styles should give the same offenses.

Currently Metrics/BlockLength will complain (when this is really not a standard block at all) and Metrics/ClassLength will not take it into account (when it should).

If we don't have a cop for to favor one style over the other, maybe we should (we do: Style/StructInheritance)

@bbatsov bbatsov added the bug label Jun 7, 2020
tejasbubane added a commit to tejasbubane/rubocop that referenced this issue Sep 29, 2020
koic added a commit that referenced this issue Sep 29, 2020
[Fix #8102] Consider class-length instead of block-length for Struct.new
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