Showing 1,441 of 1,441 total issues
Align .classify
with predecessor_token
on line 82. Open
.classify
- Read upRead up
- Exclude checks
This cop checks the indentation of the method name part in method calls that span more than one line.
Example: EnforcedStyle: aligned
# bad
while myvariable
.b
# do something
end
# good
while myvariable
.b
# do something
end
# good
Thing.a
.b
.c
Example: EnforcedStyle: indented
# good
while myvariable
.b
# do something
end
Example: EnforcedStyle: indentedrelativeto_receiver
# good
while myvariable
.a
.b
# do something
end
# good
myvariable = Thing
.a
.b
.c
Favor a normal unless-statement over a modifier clause in a multiline statement. Open
@breadcrumbs << {
label: label,
path: subpath.clone
} unless label.empty?
- Read upRead up
- Exclude checks
Checks for uses of if/unless modifiers with multiple-lines bodies.
Example:
# bad
{
result: 'this should not happen'
} unless cond
# good
{ result: 'ok' } if cond
Inconsistent indentation detected. Open
def set_project
@project = current_role.projects.find(params[:id])
end
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end
Use documents.count.zero?
instead of documents.count == 0
. Open
if documents.count == 0
- Read upRead up
- Exclude checks
This cop checks for usage of comparison operators (==
,
>
, <
) to test numbers as zero, positive, or negative.
These can be replaced by their respective predicate methods.
The cop can also be configured to do the reverse.
The cop disregards #nonzero?
as it its value is truthy or falsey,
but not true
and false
, and thus not always interchangeable with
!= 0
.
The cop ignores comparisons to global variables, since they are often
populated with objects which can be compared with integers, but are
not themselves Interger
polymorphic.
Example: EnforcedStyle: predicate (default)
# bad
foo == 0
0 > foo
bar.baz > 0
# good
foo.zero?
foo.negative?
bar.baz.positive?
Example: EnforcedStyle: comparison
# bad
foo.zero?
foo.negative?
bar.baz.positive?
# good
foo == 0
0 > foo
bar.baz > 0
Avoid using rescue
in its modifier form. Open
Integer(object) rescue false
- 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
Inconsistent indentation detected. Open
def interface_type_params
params.require(:interface_type).permit(
:test_payload
)
end
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end
Put empty method definitions on a single line. Open
def edit
end
- Read upRead up
- Exclude checks
This cop checks for the formatting of empty method definitions.
By default it enforces empty method definitions to go on a single
line (compact style), but it can be configured to enforce the end
to go on its own line (expanded style).
Note: A method definition is not considered empty if it contains comments.
Example: EnforcedStyle: compact (default)
# bad
def foo(bar)
end
def self.foo(bar)
end
# good
def foo(bar); end
def foo(bar)
# baz
end
def self.foo(bar); end
Example: EnforcedStyle: expanded
# bad
def foo(bar); end
def self.foo(bar); end
# good
def foo(bar)
end
def self.foo(bar)
end
Inconsistent indentation detected. Open
def save_annotation_documents
record_count = error_count = 0
@annotation_documents.each do |annotation_document|
type_name = annotation_document['interface_type']
interface_type = InterfaceType.find_or_create_by(name: type_name)
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end
Line is too long. [85/80] Open
response_body = JSON.parse(response.body) if response.kind_of? Net::HTTPSuccess
- Exclude checks
Line is too long. [92/80] Open
request.body = data.to_json(except: %w(created_at updated_at project_id requested_at))
- Exclude checks
Rename is_integer?
to integer?
. Open
def is_integer?(object)
- 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
Missing top-level class documentation comment. Open
class BreadcrumbBakery
- 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
Use %r
around regular expression. Open
return integer_and_action if integer_and_action =~ /[0-9]+\/\S+/
- 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\//
Avoid using rescue
in its modifier form. Open
Rails.application.routes.recognize_path(path) rescue false
- 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
Avoid using rescue
in its modifier form. Open
predecessor_token
.singularize
.classify
.constantize
.find(integer)
- 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
Inconsistent indentation detected. Open
def process_iteration_data(raw_data)
@annotation_documents = false
iterate_service = @project.iterate_service
response = json_post_request iterate_service.url,
process_iteration_data_response_hash(raw_data)
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end
Inconsistent indentation detected. Open
def merge_request(merge_datum)
auth_token = ApplicationController.generate_auth_token
merge_datum[:callback_url] = api_v1_raw_datum_url merge_datum[:raw_datum][:id],
auth_token: auth_token
merge_service = @project.merge_service
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end
Inconsistent indentation detected. Open
def params_with_associated_models
new_params = project_params
@roles.each do |role|
service_symbol = "#{role}_service".to_sym
- Read upRead up
- Exclude checks
This cops checks for inconsistent indentation.
Example:
class A
def test
puts 'hello'
puts 'world'
end
end
Line is too long. [99/80] Open
redirect_to project_raw_data_path(@project), notice: I18n.t('projects.action.create.success')
- Exclude checks
Line is too long. [90/80] Open
redirect_to project_path(@project), notice: I18n.t('projects.action.update.success')
- Exclude checks