Showing 16,957 of 16,957 total issues
Unused block argument - key
. If it's necessary, use _
or _key
as an argument name to indicate that it won't be used. Open
merge(other) do |key, oldval, newval|
- Read upRead up
- Exclude checks
This cop checks for unused block arguments.
Example:
# bad
do_something do |used, unused|
puts used
end
do_something do |bar|
puts :foo
end
define_method(:foo) do |bar|
puts :baz
end
# good
do_something do |used, _unused|
puts used
end
do_something do
puts :foo
end
define_method(:foo) do |_bar|
puts :baz
end
Example: IgnoreEmptyBlocks: true (default)
# good
do_something { |unused| }
Example: IgnoreEmptyBlocks: false
# bad
do_something { |unused| }
Example: AllowUnusedKeywordArguments: false (default)
# bad
do_something do |unused: 42|
foo
end
Example: AllowUnusedKeywordArguments: true
# good
do_something do |unused: 42|
foo
end
Align the keys of a hash literal if they span more than one line. Open
'std_tsv' => [7, :tsv, STDREP],
- Read upRead up
- Exclude checks
Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:
- key (left align keys, one space before hash rockets and values)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)
The treatment of hashes passed as the last argument to a method call can also be configured. The options are:
- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
Alternatively you can specify multiple allowed styles. That's done by passing a list of styles to EnforcedStyles.
Example: EnforcedHashRocketStyle: key (default)
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: separator
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: table
# bad
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedColonStyle: key (default)
# bad
{
foo: bar,
ba: baz
}
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: separator
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: table
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedLastArgumentHashStyle: always_inspect (default)
# Inspect both implicit and explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
# good
do_something(
foo: 1,
bar: 2
)
# good
do_something({foo: 1,
bar: 2})
# good
do_something({
foo: 1,
bar: 2
})
Example: EnforcedLastArgumentHashStyle: always_ignore
# Ignore both implicit and explicit hashes.
# good
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
Example: EnforcedLastArgumentHashStyle: ignore_implicit
# Ignore only implicit hashes.
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
Example: EnforcedLastArgumentHashStyle: ignore_explicit
# Ignore only explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
Do not define constants this way within a block. Open
FLOAT_ARGS = [2, 4].freeze
- Read upRead up
- Exclude checks
Do not define constants within a block, since the block's scope does not isolate or namespace the constant in any way.
If you are trying to define that constant once, define it outside of the block instead, or use a variable or method if defining the constant in the outer scope would be problematic.
For meta-programming, use const_set
.
Example:
# bad
task :lint do
FILES_TO_LINT = Dir['lib/*.rb']
end
# bad
describe 'making a request' do
class TestRequest; end
end
# bad
module M
extend ActiveSupport::Concern
included do
LIST = []
end
end
# good
task :lint do
files_to_lint = Dir['lib/*.rb']
end
# good
describe 'making a request' do
let(:test_request) { Class.new }
# see also `stub_const` for RSpec
end
# good
module M
extend ActiveSupport::Concern
included do
const_set(:LIST, [])
end
end
Example: AllowedMethods: ['enums'] (default)
# good
# `enums` for Typed Enums via `T::Enum` in Sorbet.
# https://sorbet.org/docs/tenum
class TestEnum < T::Enum
enums do
Foo = new("foo")
end
end
Call super
to initialize state of the parent class. Open
def initialize(database_dir)
@database_dir = database_dir
end
- Read upRead up
- Exclude checks
This cop checks for the presence of constructors and lifecycle callbacks
without calls to super
.
This cop does not consider method_missing
(and respond_to_missing?
)
because in some cases it makes sense to overtake what is considered a
missing method. In other cases, the theoretical ideal handling could be
challenging or verbose for no actual gain.
Example:
# bad
class Employee < Person
def initialize(name, salary)
@salary = salary
end
end
# good
class Employee < Person
def initialize(name, salary)
super(name)
@salary = salary
end
end
# bad
class Parent
def self.inherited(base)
do_something
end
end
# good
class Parent
def self.inherited(base)
super
do_something
end
end
Missing top-level documentation comment for class SequenceServer::INCOMPATIBLE_BLAST_DATABASES
. Open
class INCOMPATIBLE_BLAST_DATABASES < StandardError
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, constant definitions or constant visibility declarations.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
module Math
end
# good
# Description/Explanation of Person class
class Person
# ...
end
# allowed
# Class without body
class Person
end
# Namespace - A namespace can be a class or a module
# Containing a class
module Namespace
# Description/Explanation of Person class
class Person
# ...
end
end
# Containing constant visibility declaration
module Namespace
class Private
end
private_constant :Private
end
# Containing constant definition
module Namespace
Public = Class.new
end
# Macro calls
module Namespace
extend Foo
end
Example: AllowedConstants: ['ClassMethods']
# good
module A
module ClassMethods
# ...
end
end
Prefer keyword arguments for arguments with a boolean default value; use non_parse_seqids: false
instead of non_parse_seqids = false
. Open
def make_blast_database(action, file, title, type, non_parse_seqids = false)
- Read upRead up
- Exclude checks
This cop checks for places where keyword arguments can be used instead of
boolean arguments when defining methods. respond_to_missing?
method is allowed by default.
These are customizable with AllowedMethods
option.
Safety:
This cop is unsafe because changing a method signature will implicitly change behaviour.
Example:
# bad
def some_method(bar = false)
puts bar
end
# bad - common hack before keyword args were introduced
def some_method(options = {})
bar = options.fetch(:bar, false)
puts bar
end
# good
def some_method(bar: false)
puts bar
end
Example: AllowedMethods: ['some_method']
# good
def some_method(bar = false)
puts bar
end
Missing top-level documentation comment for class Hash
. Open
class Hash
- Read upRead up
- Exclude checks
This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, constant definitions or constant visibility declarations.
The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.
Example:
# bad
class Person
# ...
end
module Math
end
# good
# Description/Explanation of Person class
class Person
# ...
end
# allowed
# Class without body
class Person
end
# Namespace - A namespace can be a class or a module
# Containing a class
module Namespace
# Description/Explanation of Person class
class Person
# ...
end
end
# Containing constant visibility declaration
module Namespace
class Private
end
private_constant :Private
end
# Containing constant definition
module Namespace
Public = Class.new
end
# Macro calls
module Namespace
extend Foo
end
Example: AllowedConstants: ['ClassMethods']
# good
module A
module ClassMethods
# ...
end
end
Add empty line after guard clause. Open
end
- Read upRead up
- Exclude checks
This cop enforces empty line after guard clause
Example:
# bad
def foo
return if need_return?
bar
end
# good
def foo
return if need_return?
bar
end
# good
def foo
return if something?
return if something_different?
bar
end
# also good
def foo
if something?
do_something
return if need_return?
end
end
Use $stderr
instead of STDERR
. Open
Logger.new(STDERR, Logger::WARN)
- Read upRead up
- Exclude checks
This cop enforces the use of $stdout/$stderr/$stdin
instead of STDOUT/STDERR/STDIN
.
STDOUT/STDERR/STDIN
are constants, and while you can actually
reassign (possibly to redirect some stream) constants in Ruby, you'll get
an interpreter warning if you do so.
Safety:
Autocorrection is unsafe because STDOUT
and $stdout
may point to different
objects, for example.
Example:
# bad
STDOUT.puts('hello')
hash = { out: STDOUT, key: value }
def m(out = STDOUT)
out.puts('hello')
end
# good
$stdout.puts('hello')
hash = { out: $stdout, key: value }
def m(out = $stdout)
out.puts('hello')
end
Align the keys of a hash literal if they span more than one line. Open
'csv' => [10, :csv],
- Read upRead up
- Exclude checks
Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:
- key (left align keys, one space before hash rockets and values)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)
The treatment of hashes passed as the last argument to a method call can also be configured. The options are:
- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
Alternatively you can specify multiple allowed styles. That's done by passing a list of styles to EnforcedStyles.
Example: EnforcedHashRocketStyle: key (default)
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: separator
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: table
# bad
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedColonStyle: key (default)
# bad
{
foo: bar,
ba: baz
}
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: separator
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: table
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedLastArgumentHashStyle: always_inspect (default)
# Inspect both implicit and explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
# good
do_something(
foo: 1,
bar: 2
)
# good
do_something({foo: 1,
bar: 2})
# good
do_something({
foo: 1,
bar: 2
})
Example: EnforcedLastArgumentHashStyle: always_ignore
# Ignore both implicit and explicit hashes.
# good
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
Example: EnforcedLastArgumentHashStyle: ignore_implicit
# Ignore only implicit hashes.
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
Example: EnforcedLastArgumentHashStyle: ignore_explicit
# Ignore only explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
:send
member overrides Struct#send
and it may be unexpected. Open
:sstart, :send, :qframe, :sframe, :identity, :positives,
- Read upRead up
- Exclude checks
This cop checks unexpected overrides of the Struct
built-in methods
via Struct.new
.
Example:
# bad
Bad = Struct.new(:members, :clone, :count)
b = Bad.new([], true, 1)
b.members #=> [] (overriding `Struct#members`)
b.clone #=> true (overriding `Object#clone`)
b.count #=> 1 (overriding `Enumerable#count`)
# good
Good = Struct.new(:id, :name)
g = Good.new(1, "foo")
g.members #=> [:id, :name]
g.clone #=> #<struct good id="1," name="foo">
g.count #=> 2</struct>
Call super
to initialize state of the parent class. Open
def initialize(database_dir)
@database_dir = database_dir
end
- Read upRead up
- Exclude checks
This cop checks for the presence of constructors and lifecycle callbacks
without calls to super
.
This cop does not consider method_missing
(and respond_to_missing?
)
because in some cases it makes sense to overtake what is considered a
missing method. In other cases, the theoretical ideal handling could be
challenging or verbose for no actual gain.
Example:
# bad
class Employee < Person
def initialize(name, salary)
@salary = salary
end
end
# good
class Employee < Person
def initialize(name, salary)
super(name)
@salary = salary
end
end
# bad
class Parent
def self.inherited(base)
do_something
end
end
# good
class Parent
def self.inherited(base)
super
do_something
end
end
Call super
to initialize state of the parent class. Open
def initialize(cmd, out)
@cmd = cmd
@out = out
end
- Read upRead up
- Exclude checks
This cop checks for the presence of constructors and lifecycle callbacks
without calls to super
.
This cop does not consider method_missing
(and respond_to_missing?
)
because in some cases it makes sense to overtake what is considered a
missing method. In other cases, the theoretical ideal handling could be
challenging or verbose for no actual gain.
Example:
# bad
class Employee < Person
def initialize(name, salary)
@salary = salary
end
end
# good
class Employee < Person
def initialize(name, salary)
super(name)
@salary = salary
end
end
# bad
class Parent
def self.inherited(base)
do_something
end
end
# good
class Parent
def self.inherited(base)
super
do_something
end
end
Call super
to initialize state of the parent class. Open
def initialize(exitstatus, stdout: nil, stderr: nil)
@exitstatus = exitstatus
@stdout = stdout
@stderr = stderr
end
- Read upRead up
- Exclude checks
This cop checks for the presence of constructors and lifecycle callbacks
without calls to super
.
This cop does not consider method_missing
(and respond_to_missing?
)
because in some cases it makes sense to overtake what is considered a
missing method. In other cases, the theoretical ideal handling could be
challenging or verbose for no actual gain.
Example:
# bad
class Employee < Person
def initialize(name, salary)
@salary = salary
end
end
# good
class Employee < Person
def initialize(name, salary)
super(name)
@salary = salary
end
end
# bad
class Parent
def self.inherited(base)
do_something
end
end
# good
class Parent
def self.inherited(base)
super
do_something
end
end
Align the keys of a hash literal if they span more than one line. Open
icon: 'fa-external-link'
- Read upRead up
- Exclude checks
Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:
- key (left align keys, one space before hash rockets and values)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)
The treatment of hashes passed as the last argument to a method call can also be configured. The options are:
- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
Alternatively you can specify multiple allowed styles. That's done by passing a list of styles to EnforcedStyles.
Example: EnforcedHashRocketStyle: key (default)
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: separator
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: table
# bad
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedColonStyle: key (default)
# bad
{
foo: bar,
ba: baz
}
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: separator
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: table
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedLastArgumentHashStyle: always_inspect (default)
# Inspect both implicit and explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
# good
do_something(
foo: 1,
bar: 2
)
# good
do_something({foo: 1,
bar: 2})
# good
do_something({
foo: 1,
bar: 2
})
Example: EnforcedLastArgumentHashStyle: always_ignore
# Ignore both implicit and explicit hashes.
# good
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
Example: EnforcedLastArgumentHashStyle: ignore_implicit
# Ignore only implicit hashes.
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
Example: EnforcedLastArgumentHashStyle: ignore_explicit
# Ignore only explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
Align the keys of a hash literal if they span more than one line. Open
icon: 'fa-external-link'
- Read upRead up
- Exclude checks
Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:
- key (left align keys, one space before hash rockets and values)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)
The treatment of hashes passed as the last argument to a method call can also be configured. The options are:
- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
Alternatively you can specify multiple allowed styles. That's done by passing a list of styles to EnforcedStyles.
Example: EnforcedHashRocketStyle: key (default)
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: separator
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: table
# bad
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedColonStyle: key (default)
# bad
{
foo: bar,
ba: baz
}
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: separator
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: table
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedLastArgumentHashStyle: always_inspect (default)
# Inspect both implicit and explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
# good
do_something(
foo: 1,
bar: 2
)
# good
do_something({foo: 1,
bar: 2})
# good
do_something({
foo: 1,
bar: 2
})
Example: EnforcedLastArgumentHashStyle: always_ignore
# Ignore both implicit and explicit hashes.
# good
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
Example: EnforcedLastArgumentHashStyle: ignore_implicit
# Ignore only implicit hashes.
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
Example: EnforcedLastArgumentHashStyle: ignore_explicit
# Ignore only explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
Align the elements of an array literal if they span more than one line. Open
SequenceServer::NUM_THREADS_INCORRECT => e
- Read upRead up
- Exclude checks
Here we check if the elements of a multi-line array literal are aligned.
Example: EnforcedStyle: withfirstelement (default)
# good
array = [1, 2, 3,
4, 5, 6]
array = ['run',
'forrest',
'run']
# bad
array = [1, 2, 3,
4, 5, 6]
array = ['run',
'forrest',
'run']
Example: EnforcedStyle: withfixedindentation
# good
array = [1, 2, 3,
4, 5, 6]
# bad
array = [1, 2, 3,
4, 5, 6]
Align the keys of a hash literal if they span more than one line. Open
'full_tsv' => [7, :tsv, OUTFMT_SPECIFIERS],
- Read upRead up
- Exclude checks
Check that the keys, separators, and values of a multi-line hash literal are aligned according to configuration. The configuration options are:
- key (left align keys, one space before hash rockets and values)
- separator (align hash rockets and colons, right align keys)
- table (left align keys, hash rockets, and values)
The treatment of hashes passed as the last argument to a method call can also be configured. The options are:
- always_inspect
- always_ignore
- ignore_implicit (without curly braces)
Alternatively you can specify multiple allowed styles. That's done by passing a list of styles to EnforcedStyles.
Example: EnforcedHashRocketStyle: key (default)
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: separator
# bad
{
:foo => bar,
:ba => baz
}
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedHashRocketStyle: table
# bad
{
:foo => bar,
:ba => baz
}
# good
{
:foo => bar,
:ba => baz
}
Example: EnforcedColonStyle: key (default)
# bad
{
foo: bar,
ba: baz
}
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: separator
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedColonStyle: table
# bad
{
foo: bar,
ba: baz
}
# good
{
foo: bar,
ba: baz
}
Example: EnforcedLastArgumentHashStyle: always_inspect (default)
# Inspect both implicit and explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
# good
do_something(
foo: 1,
bar: 2
)
# good
do_something({foo: 1,
bar: 2})
# good
do_something({
foo: 1,
bar: 2
})
Example: EnforcedLastArgumentHashStyle: always_ignore
# Ignore both implicit and explicit hashes.
# good
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
Example: EnforcedLastArgumentHashStyle: ignore_implicit
# Ignore only implicit hashes.
# bad
do_something({foo: 1,
bar: 2})
# good
do_something(foo: 1,
bar: 2)
Example: EnforcedLastArgumentHashStyle: ignore_explicit
# Ignore only explicit hashes.
# bad
do_something(foo: 1,
bar: 2)
# good
do_something({foo: 1,
bar: 2})
:length
member overrides Struct#length
and it may be unexpected. Open
:length, :sciname, :qcovs, :hsps) do
- Read upRead up
- Exclude checks
This cop checks unexpected overrides of the Struct
built-in methods
via Struct.new
.
Example:
# bad
Bad = Struct.new(:members, :clone, :count)
b = Bad.new([], true, 1)
b.members #=> [] (overriding `Struct#members`)
b.clone #=> true (overriding `Object#clone`)
b.count #=> 1 (overriding `Enumerable#count`)
# good
Good = Struct.new(:id, :name)
g = Good.new(1, "foo")
g.members #=> [:id, :name]
g.clone #=> #<struct good id="1," name="foo">
g.count #=> 2</struct>
:length
member overrides Struct#length
and it may be unexpected. Open
Query = Struct.new(:report, :number, :def, :length, :hits) do
- Read upRead up
- Exclude checks
This cop checks unexpected overrides of the Struct
built-in methods
via Struct.new
.
Example:
# bad
Bad = Struct.new(:members, :clone, :count)
b = Bad.new([], true, 1)
b.members #=> [] (overriding `Struct#members`)
b.clone #=> true (overriding `Object#clone`)
b.count #=> 1 (overriding `Enumerable#count`)
# good
Good = Struct.new(:id, :name)
g = Good.new(1, "foo")
g.members #=> [:id, :name]
g.clone #=> #<struct good id="1," name="foo">
g.count #=> 2</struct>