Showing 1,441 of 1,441 total issues
Pass &:relevant_attributes
as an argument to map
instead of a block. Open
annotation_documents: annotation_documents.map { |document| document.relevant_attributes }
- Read upRead up
- Exclude checks
Use symbols as procs when possible.
Example:
# bad
something.map { |s| s.upcase }
# good
something.map(&:upcase)
Freeze mutable objects assigned to constants. Open
MIME_TYPES = {
text: [
'text/plain',
'text/markdown',
'text/html',
- Read upRead up
- Exclude checks
This cop checks whether some constant value isn't a mutable literal (e.g. array or hash).
Example:
# bad
CONST = [1, 2, 3]
# good
CONST = [1, 2, 3].freeze
Redundant self
detected. Open
self.filename
- Read upRead up
- Exclude checks
This cop checks for redundant uses of self
.
The usage of self
is only needed when:
Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.
Calling an attribute writer to prevent an local variable assignment.
Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.
Note we allow uses of self
with operators because it would be awkward
otherwise.
Example:
# bad
def foo(bar)
self.baz
end
# good
def foo(bar)
self.bar # Resolves name clash with the argument.
end
def foo
bar = 1
self.bar # Resolves name clash with the local variable.
end
def foo
%w[x y z].select do |bar|
self.bar == bar # Resolves name clash with argument of the block.
end
end
Line exceeds maximum allowed length Open
apiCall: (requestOptions, responseProcessor = false, postUpdateCallback = false) ->
- Exclude checks
Line is too long. [91/80] Open
return response.kind_of?(Net::HTTPSuccess) || response.kind_of?(Net::HTTPRedirection)
- Exclude checks
Use %r
around regular expression. Open
content_type: /(text\/.*|inode\/x-empty)/
- Read upRead up
- Exclude checks
This cop enforces using // or %r around regular expressions.
Example: EnforcedStyle: slashes (default)
# bad
snake_case = %r{^[\dA-Z_]+$}
# bad
regex = %r{
foo
(bar)
(baz)
}x
# good
snake_case = /^[\dA-Z_]+$/
# good
regex = /
foo
(bar)
(baz)
/x
Example: EnforcedStyle: percent_r
# bad
snake_case = /^[\dA-Z_]+$/
# bad
regex = /
foo
(bar)
(baz)
/x
# good
snake_case = %r{^[\dA-Z_]+$}
# good
regex = %r{
foo
(bar)
(baz)
}x
Example: EnforcedStyle: mixed
# bad
snake_case = %r{^[\dA-Z_]+$}
# bad
regex = /
foo
(bar)
(baz)
/x
# good
snake_case = /^[\dA-Z_]+$/
# good
regex = %r{
foo
(bar)
(baz)
}x
Example: AllowInnerSlashes: false (default)
# If `false`, the cop will always recommend using `%r` if one or more
# slashes are found in the regexp string.
# bad
x =~ /home\//
# good
x =~ %r{home/}
Example: AllowInnerSlashes: true
# good
x =~ /home\//
Redundant self
detected. Open
self.necessary_interface_types.each do |interface_type|
- Read upRead up
- Exclude checks
This cop checks for redundant uses of self
.
The usage of self
is only needed when:
Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.
Calling an attribute writer to prevent an local variable assignment.
Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.
Note we allow uses of self
with operators because it would be awkward
otherwise.
Example:
# bad
def foo(bar)
self.baz
end
# good
def foo(bar)
self.bar # Resolves name clash with the argument.
end
def foo
bar = 1
self.bar # Resolves name clash with the local variable.
end
def foo
%w[x y z].select do |bar|
self.bar == bar # Resolves name clash with argument of the block.
end
end
Align the parameters of a method call if they span more than one line. Open
uniqueness: true,
format: {
with: /\Ahttp(|s)\:\/\/\S+\z/,
message: I18n.t('activerecord.errors.models.service.attributes.url.regex_mismatch')
}
- Read upRead up
- Exclude checks
Here we check if the parameters on a multi-line method call or definition are aligned.
Example: EnforcedStyle: withfirstparameter (default)
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Example: EnforcedStyle: withfixedindentation
# good
foo :bar,
:baz
# bad
foo :bar,
:baz
Do not use ::
for method calls. Open
Timeout::timeout(timeout) do
- Read upRead up
- Exclude checks
This cop checks for methods invoked via the :: operator instead of the . operator (like FileUtils::rmdir instead of FileUtils.rmdir).
Example:
# bad
Timeout::timeout(500) { do_something }
FileUtils::rmdir(dir)
Marshal::dump(obj)
# good
Timeout.timeout(500) { do_something }
FileUtils.rmdir(dir)
Marshal.dump(obj)
Line exceeds maximum allowed length Open
# spec path and it'll be included in the default suite automatically. If you want to customize suites, check out the
- Exclude checks
Indent )
the same as the start of the line where (
is. Open
)
- Read upRead up
- Exclude checks
This cops checks the indentation of hanging closing parentheses in
method calls, method definitions, and grouped expressions. A hanging
closing parenthesis means )
preceded by a line break.
Example:
# good: when x is on its own line, indent this way
func(
x,
y
)
# good: when x follows opening parenthesis, align parentheses
a = b * (x +
y
)
# bad
def func(
x,
y
)
end
Indent the first parameter one step more than the start of the previous line. Open
File.new(raw_datum.data.path).read
- Read upRead up
- Exclude checks
This cop checks the indentation of the first parameter in a method call. Parameters after the first one are checked by Style/AlignParameters, not by this cop.
Example:
# bad
some_method(
first_param,
second_param)
# good
some_method(
first_param,
second_param)
Redundant self
detected. Open
self.send("#{role}_service=", role_services.first) if role_services.length == 1
- Read upRead up
- Exclude checks
This cop checks for redundant uses of self
.
The usage of self
is only needed when:
Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.
Calling an attribute writer to prevent an local variable assignment.
Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.
Note we allow uses of self
with operators because it would be awkward
otherwise.
Example:
# bad
def foo(bar)
self.baz
end
# good
def foo(bar)
self.bar # Resolves name clash with the argument.
end
def foo
bar = 1
self.bar # Resolves name clash with the local variable.
end
def foo
%w[x y z].select do |bar|
self.bar == bar # Resolves name clash with argument of the block.
end
end
Avoid using rescue
in its modifier form. Open
selected_interfaces[interface_type.name] = interface.title rescue nil
- Read upRead up
- Exclude checks
This cop checks for uses of rescue in its modifier form.
Example:
# bad
some_method rescue handle_error
# good
begin
some_method
rescue
handle_error
end
Rename is_available?
to available?
. Open
def is_available?
- Read upRead up
- Exclude checks
This cop makes sure that predicates are named properly.
Example:
# bad
def is_even?(value)
end
# good
def even?(value)
end
# bad
def has_value?
end
# good
def value?
end
Redundant self
detected. Open
self.title
- Read upRead up
- Exclude checks
This cop checks for redundant uses of self
.
The usage of self
is only needed when:
Sending a message to same object with zero arguments in presence of a method name clash with an argument or a local variable.
Calling an attribute writer to prevent an local variable assignment.
Note, with using explicit self you can only send messages with public or protected scope, you cannot send private messages this way.
Note we allow uses of self
with operators because it would be awkward
otherwise.
Example:
# bad
def foo(bar)
self.baz
end
# good
def foo(bar)
self.bar # Resolves name clash with the argument.
end
def foo
bar = 1
self.bar # Resolves name clash with the local variable.
end
def foo
%w[x y z].select do |bar|
self.bar == bar # Resolves name clash with argument of the block.
end
end
Line exceeds maximum allowed length Open
url: "#{this.dalphiBaseUrl}/projects/#{_this.projectId}/annotation_documents/next",
- Exclude checks
Line exceeds maximum allowed length Open
console.log "AnnotationDocumentManager: loaded known annotation document (history request)"
- Exclude checks
Line exceeds maximum allowed length Open
_this.generalResponseHandlingWithObject(postUpdateCallback, _this.errorObjects[404])
- Exclude checks
Use attr_writer
to define trivial writer methods. Open
def validator_compiled_java_script=(val)
- Read upRead up
- Exclude checks
This cop looks for trivial reader/writer methods, that could have been created with the attr_* family of functions automatically.
Example:
# bad
def foo
@foo
end
def bar=(val)
@bar = val
end
def self.baz
@baz
end
# good
attr_reader :foo
attr_writer :bar
class << self
attr_reader :baz
end