Showing 1,441 of 1,441 total issues
Align the parameters of a method call if they span more than one line. Open
presence: true
- 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
Use %i
or %I
for an array of symbols. Open
[
:shape,
:data,
:project_id,
:filename
- Read upRead up
- Exclude checks
This cop can check for array literals made up of symbols that are not using the %i() syntax.
Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize of
3` will not enforce a style on an array
of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%i[foo bar baz]
# bad
[:foo, :bar, :baz]
Example: EnforcedStyle: brackets
# good
[:foo, :bar, :baz]
# bad
%i[foo bar baz]
Line is too long. [83/80] Open
return interface_types unless interface_type_names && interface_type_names.any?
- Exclude checks
Line is too long. [98/80] Open
annotation_documents: annotation_documents.map { |document| document.relevant_attributes }
- Exclude checks
Line is too long. [92/80] Open
File.write(raw_datum.data.path, Base64.decode64(params['data']).force_encoding('utf-8'))
- Exclude checks
Missing top-level class documentation comment. Open
class Project < ApplicationRecord
- 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, or constant definitions.
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
# good
# Description/Explanation of Person class
class Person
# ...
end
Line exceeds maximum allowed length Open
_this.loadAnnotationDocumentWithId(history.state.annotationDocumentId, calleeCallback)
- Exclude checks
Redundant return
detected. Open
return File.read(file)
- Read upRead up
- Exclude checks
This cop checks for redundant return
expressions.
Example:
def test
return something
end
def test
one
two
three
return something
end
It should be extended to handle methods whose body is if/else or a case expression with a default branch.
Line exceeds maximum allowed length Open
$('.compatibility-state-sign', _this.$compatibilityCheck).each (index, element) ->
- Exclude checks
Align the parameters of a method call if they span more than one line. Open
presence: true,
format: { with: /\A[\w\.\-\_]+\z/ }
- 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
Line exceeds maximum allowed length Open
this.testPayloadEditor = this.initAceEditorWithId('test-payload-editor', 'json')
- Exclude checks
Line is too long. [94/80] Open
data['interface_types'] = InterfaceType.convert_interface_types(data['interface_types'])
- Exclude checks
Line exceeds maximum allowed length Open
this.stylesheetEditor = this.initAceEditorWithId('stylesheet-editor', 'scss')
- Exclude checks
Align the parameters of a method call if they span more than one line. Open
presence: true,
inclusion: { in: SHAPES }
- 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
Line is too long. [87/80] Open
data: File.open("#{temp_dir}/#{extraction_filename.force_encoding('utf-8')}")
- Exclude checks
Redundant self
detected. Open
project: self.project,
- 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
Use %i
or %I
for an array of symbols. Open
scope: [:iteration_index, :project_id]
- Read upRead up
- Exclude checks
This cop can check for array literals made up of symbols that are not using the %i() syntax.
Alternatively, it checks for symbol arrays using the %i() syntax on projects which do not want to use that syntax.
Configuration option: MinSize
If set, arrays with fewer elements than this value will not trigger the
cop. For example, a MinSize of
3` will not enforce a style on an array
of 2 or fewer elements.
Example: EnforcedStyle: percent (default)
# good
%i[foo bar baz]
# bad
[:foo, :bar, :baz]
Example: EnforcedStyle: brackets
# good
[:foo, :bar, :baz]
# bad
%i[foo bar baz]
Line exceeds maximum allowed length Open
$('.selected-interfaces .blank-slate').removeClass('no-display') if state == 3
- 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
Use each_key
instead of keys.each
. Open
Service.roles.keys.each do |role|
- Read upRead up
- Exclude checks
This cop checks for uses of each_key
and each_value
Hash methods.
Note: If you have an array of two-element arrays, you can put parentheses around the block arguments to indicate that you're not working with a hash, and suppress RuboCop offenses.
Example:
# bad
hash.keys.each { |k| p k }
hash.values.each { |v| p v }
hash.each { |k, _v| p k }
hash.each { |_k, v| p v }
# good
hash.each_key { |k| p k }
hash.each_value { |v| p v }