Module has too many lines. [134/100] Open
module MiGA::Cli::Action::Doctor::Operations
##
# Perform refdb operation with MiGA::Cli +cli+
def check_refdb(cli)
cli.say 'Checking index format of reference database'
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [28/10] Open
def check_mts(cli)
cli.say 'Looking for unarchived MyTaxa Scan runs'
cli.load_project.each_dataset do |d|
res = d.result(:mytaxa_scan)
next if res.nil?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [20/10] Open
def check_cds(cli)
cli.say 'Looking for unzipped genes or proteins'
n, k = cli.load_project.dataset_names.size, 0
cli.load_project.each_dataset do |d|
cli.advance('Datasets:', k += 1, n, false)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method has too many lines. [20/10] Open
def check_files(cli)
cli.say 'Looking for outdated files in results'
n, k = cli.load_project.dataset_names.size, 0
cli.load_project.each_dataset do |d|
cli.advance('Datasets:', k += 1, n, false)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Method check_mts
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def check_mts(cli)
cli.say 'Looking for unarchived MyTaxa Scan runs'
cli.load_project.each_dataset do |d|
res = d.result(:mytaxa_scan)
next if res.nil?
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method has too many lines. [17/10] Open
def check_ess(cli)
cli.say 'Looking for outdated essential genes'
cli.load_project.each_dataset do |d|
res = d.result(:essential_genes)
next if res.nil?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for check_mts is too high. [22.65/15] Open
def check_mts(cli)
cli.say 'Looking for unarchived MyTaxa Scan runs'
cli.load_project.each_dataset do |d|
res = d.result(:mytaxa_scan)
next if res.nil?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for check_cds is too high. [21.19/15] Open
def check_cds(cli)
cli.say 'Looking for unzipped genes or proteins'
n, k = cli.load_project.dataset_names.size, 0
cli.load_project.each_dataset do |d|
cli.advance('Datasets:', k += 1, n, false)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Method has too many lines. [15/10] Open
def check_status(cli)
cli.say 'Updating metadata status'
p = cli.load_project
n = p.dataset_names.size
(0 .. cli[:threads] - 1).map do |i|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.
Assignment Branch Condition size for check_ess is too high. [19.52/15] Open
def check_ess(cli)
cli.say 'Looking for outdated essential genes'
cli.load_project.each_dataset do |d|
res = d.result(:essential_genes)
next if res.nil?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for check_status is too high. [18.79/15] Open
def check_status(cli)
cli.say 'Updating metadata status'
p = cli.load_project
n = p.dataset_names.size
(0 .. cli[:threads] - 1).map do |i|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Assignment Branch Condition size for check_files is too high. [17.58/15] Open
def check_files(cli)
cli.say 'Looking for outdated files in results'
n, k = cli.load_project.dataset_names.size, 0
cli.load_project.each_dataset do |d|
cli.advance('Datasets:', k += 1, n, false)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric
Cyclomatic complexity for check_mts is too high. [7/6] Open
def check_mts(cli)
cli.say 'Looking for unarchived MyTaxa Scan runs'
cli.load_project.each_dataset do |d|
res = d.result(:mytaxa_scan)
next if res.nil?
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.
An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.
Method check_mts
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def check_mts(cli)
cli.say 'Looking for unarchived MyTaxa Scan runs'
cli.load_project.each_dataset do |d|
res = d.result(:mytaxa_scan)
next if res.nil?
- Create a ticketCreate a ticket
Method check_cds
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def check_cds(cli)
cli.say 'Looking for unzipped genes or proteins'
n, k = cli.load_project.dataset_names.size, 0
cli.load_project.each_dataset do |d|
cli.advance('Datasets:', k += 1, n, false)
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method check_files
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def check_files(cli)
cli.say 'Looking for outdated files in results'
n, k = cli.load_project.dataset_names.size, 0
cli.load_project.each_dataset do |d|
cli.advance('Datasets:', k += 1, n, false)
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method check_ess
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def check_ess(cli)
cli.say 'Looking for outdated essential genes'
cli.load_project.each_dataset do |d|
res = d.result(:essential_genes)
next if res.nil?
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method check_status
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def check_status(cli)
cli.say 'Updating metadata status'
p = cli.load_project
n = p.dataset_names.size
(0 .. cli[:threads] - 1).map do |i|
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
TODO found Open
# TODO: Find 95%ANI clusters with entries from different species
- Create a ticketCreate a ticket
- Exclude checks
TODO found Open
# TODO: Find AAI values too high or too low for each LCA rank
- Create a ticketCreate a ticket
- Exclude checks
TODO found Open
# TODO: Find different 95%ANI clusters with genomes from the same species
- Create a ticketCreate a ticket
- Exclude checks
Use next
to skip iteration. Open
unless ok
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Use next
to skip iteration instead of a condition at the end.
Example: EnforcedStyle: skipmodifierifs (default)
# bad
[1, 2].each do |a|
if a == 1
puts a
end
end
# good
[1, 2].each do |a|
next unless a == 1
puts a
end
# good
[1, 2].each do |o|
puts o unless o == 1
end
Example: EnforcedStyle: always
# With `always` all conditions at the end of an iteration needs to be
# replaced by next - with `skip_modifier_ifs` the modifier if like
# this one are ignored: `[1, 2].each { |a| return 'yes' if a == 1 }`
# bad
[1, 2].each do |o|
puts o unless o == 1
end
# bad
[1, 2].each do |a|
if a == 1
puts a
end
end
# good
[1, 2].each do |a|
next unless a == 1
puts a
end
Missing magic comment # frozen_string_literal: true
. Open
module MiGA::Cli::Action::Doctor::Operations
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop is designed to help upgrade to Ruby 3.0. It will add the
comment # frozen_string_literal: true
to the top of files to
enable frozen string literals. Frozen string literals may be default
in Ruby 3.0. The comment will be added below a shebang and encoding
comment. The frozen string literal comment is only valid in Ruby 2.3+.
Example: EnforcedStyle: when_needed (default)
# The `when_needed` style will add the frozen string literal comment
# to files only when the `TargetRubyVersion` is set to 2.3+.
# bad
module Foo
# ...
end
# good
# frozen_string_literal: true
module Foo
# ...
end
Example: EnforcedStyle: always
# The `always` style will always add the frozen string literal comment
# to a file, regardless of the Ruby version or if `freeze` or `<<` are
# called on a string literal.
# bad
module Bar
# ...
end
# good
# frozen_string_literal: true
module Bar
# ...
end
Example: EnforcedStyle: never
# The `never` will enforce that the frozen string literal comment does
# not exist in a file.
# bad
# frozen_string_literal: true
module Baz
# ...
end
# good
module Baz
# ...
end
Do not use parallel assignment. Open
n, k = cli.load_project.dataset_names.size, 0
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for simple usages of parallel assignment. This will only complain when the number of variables being assigned matched the number of assigning variables.
Example:
# bad
a, b, c = 1, 2, 3
a, b, c = [1, 2, 3]
# good
one, two = *foo
a, b = foo()
a, b = b, a
a = 1
b = 2
c = 3
Missing top-level module documentation comment. Open
module MiGA::Cli::Action::Doctor::Operations
- Read upRead up
- Create a ticketCreate a ticket
- 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 i.zero?
instead of i == 0
. Open
cli.advance('Datasets:', k, n, false) if i == 0
- Read upRead up
- Create a ticketCreate a ticket
- 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
Use next
to skip iteration. Open
if file !~ /\.gz/
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Use next
to skip iteration instead of a condition at the end.
Example: EnforcedStyle: skipmodifierifs (default)
# bad
[1, 2].each do |a|
if a == 1
puts a
end
end
# good
[1, 2].each do |a|
next unless a == 1
puts a
end
# good
[1, 2].each do |o|
puts o unless o == 1
end
Example: EnforcedStyle: always
# With `always` all conditions at the end of an iteration needs to be
# replaced by next - with `skip_modifier_ifs` the modifier if like
# this one are ignored: `[1, 2].each { |a| return 'yes' if a == 1 }`
# bad
[1, 2].each do |o|
puts o unless o == 1
end
# bad
[1, 2].each do |a|
if a == 1
puts a
end
end
# good
[1, 2].each do |a|
next unless a == 1
puts a
end
Space inside range literal. Open
(0 .. cli[:threads] - 1).map do |i|
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for spaces inside range literals.
Example:
# bad
1 .. 3
# good
1..3
# bad
'a' .. 'z'
# good
'a'..'z'
Useless assignment to variable - md
. Open
md = p&.metadata
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop checks for every useless assignment to local variable in every
scope.
The basic idea for this cop was from the warning of ruby -cw
:
assigned but unused variable - foo
Currently this cop has advanced logic that detects unreferenced reassignments and properly handles varied cases such as branch, loop, rescue, ensure, etc.
Example:
# bad
def some_method
some_var = 1
do_something
end
Example:
# good
def some_method
some_var = 1
do_something(some_var)
end
Do not use parallel assignment. Open
n, k = cli.load_project.dataset_names.size, 0
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks for simple usages of parallel assignment. This will only complain when the number of variables being assigned matched the number of assigning variables.
Example:
# bad
a, b, c = 1, 2, 3
a, b, c = [1, 2, 3]
# good
one, two = *foo
a, b = foo()
a, b = b, a
a = 1
b = 2
c = 3