Showing 840 of 840 total issues
Use dependencies.count.zero?
instead of dependencies.count == 0
. Open
return if !dependencies || dependencies.count == 0 || !cartfile_path
- 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
Freeze mutable objects assigned to constants. Open
RAMBLER_CATALOG_REPO = 'https://github.com/rambler-digital-solutions/generamba-catalog'
- 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
Extra empty line detected at class body end. Open
end
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of classes match the configuration.
Example: EnforcedStyle: empty_lines
# good
class Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
class Foo
class Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
class Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
class Foo
def bar
# ...
end
end
Freeze mutable objects assigned to constants. Open
TEMPLATE_NAME_KEY = 'name'
- 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
Freeze mutable objects assigned to constants. Open
TEMPLATE_AUTHOR_KEY = 'author'
- 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
Line is too long. [88/80] Open
file_path_const_value = Generamba.const_get(target_type.upcase + '_FILE_PATH_KEY')
- Exclude checks
Final newline missing. Open
end
- Exclude checks
Prefer to_s
over string interpolation. Open
template_path = "#{template_dir}"
- Read upRead up
- Exclude checks
This cop checks for strings that are just an interpolated expression.
Example:
# bad
"#{@var}"
# good
@var.to_s
# good if @var is already a String
@var
Extra empty line detected at module body beginning. Open
# Incapsulates the logic of installing Generamba templates from the template catalog
- Read upRead up
- Exclude checks
This cops checks if empty lines around the bodies of modules match the configuration.
Example: EnforcedStyle: empty_lines
# good
module Foo
def bar
# ...
end
end
Example: EnforcedStyle: emptylinesexcept_namespace
# good
module Foo
module Bar
# ...
end
end
Example: EnforcedStyle: emptylinesspecial
# good
module Foo
def bar; end
end
Example: EnforcedStyle: noemptylines (default)
# good
module Foo
def bar
# ...
end
end
Prefer !expression.nil?
over expression != nil
. Open
template_path != nil
- Read upRead up
- Exclude checks
This cop checks for non-nil checks, which are usually redundant.
Example:
# bad
if x != nil
end
# good (when not allowing semantic changes)
# bad (when allowing semantic changes)
if !x.nil?
end
# good (when allowing semantic changes)
if x
end
Non-nil checks are allowed if they are the final nodes of predicate.
# good
def signed_in?
!current_user.nil?
end
Freeze mutable objects assigned to constants. Open
CARTFILE_PATH_KEY = 'cartfile_path'
- 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
Freeze mutable objects assigned to constants. Open
RAMBASPEC_EXTENSION = '.rambaspec'
- 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
Final newline missing. Open
end
- Exclude checks
Freeze mutable objects assigned to constants. Open
TEMPLATE_FILE_IS_RESOURCE_KEY = 'is_resource'
- 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
Avoid using {...}
for multi-line blocks. Open
}.each { |catalog_path|
- Read upRead up
- Exclude checks
Check for uses of braces or do/end around single line or multi-line blocks.
Example: EnforcedStyle: linecountbased (default)
# bad - single line block
items.each do |item| item / 5 end
# good - single line block
items.each { |item| item / 5 }
# bad - multi-line block
things.map { |thing|
something = thing.some_method
process(something)
}
# good - multi-line block
things.map do |thing|
something = thing.some_method
process(something)
end
Example: EnforcedStyle: semantic
# Prefer `do...end` over `{...}` for procedural blocks.
# return value is used/assigned
# bad
foo = map do |x|
x
end
puts (map do |x|
x
end)
# return value is not used out of scope
# good
map do |x|
x
end
# Prefer `{...}` over `do...end` for functional blocks.
# return value is not used out of scope
# bad
each { |x|
x
}
# return value is used/assigned
# good
foo = map { |x|
x
}
map { |x|
x
}.inspect
Example: EnforcedStyle: bracesforchaining
# bad
words.each do |word|
word.flip.flop
end.join("-")
# good
words.each { |word|
word.flip.flop
}.join("-")
Unused method argument - template_declaration
. If it's necessary, use _
or _template_declaration
as an argument name to indicate that it won't be used. You can also write as install_template(*)
if you want the method to accept any arguments but don't care about them. Open
def install_template(template_declaration)
- Read upRead up
- Exclude checks
This cop checks for unused method arguments.
Example:
# bad
def some_method(used, unused, _unused_but_allowed)
puts used
end
Example:
# good
def some_method(used, _unused, _unused_but_allowed)
puts used
end
Line is too long. [94/80] Open
rambaspec_valid = Generamba::RambaspecValidator.validate_spec(template_name, local_path)
- Exclude checks
Line is too long. [86/80] Open
error_description = "#{template_name + RAMBASPEC_EXTENSION} is not valid.".red
- Exclude checks
Final newline missing. Open
end
- Exclude checks
Avoid multi-line chains of blocks. Open
}.each { |catalog_path|
- Read upRead up
- Exclude checks
This cop checks for chaining of a block after another block that spans multiple lines.
Example:
Thread.list.find_all do |t|
t.alive?
end.map do |t|
t.object_id
end