struct-new-override
What it does
Section titled “What it does”Reports a Struct.new member that has the name of a method of Struct (:hash, :size, :count).
Why it matters
Section titled “Why it matters”The generated accessor replaces the method of Struct, which other code and the class itself depend on. hash breaks use as a hash key and size breaks code that reads the members.
To fix, rename the member.
Example
Section titled “Example”...h.key?(x.id)...2.times { f }Struct.new(:hash, :name)...Configuration
Section titled “Configuration”ruby: lint: rules: struct-new-override: warn # off, warn (default), errorEnabled by the presets: ruby/rubocop.
Suppress one line with sudsy-disable-next-line struct-new-override in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| rubocop | Lint/StructNewOverride |
full |