Module has too many lines. [127/100] Open
module MiGA::Cli::Action::Download::Ncbi
include MiGA::Cli::Action::Download::Base
def cli_task_flags(opt)
cli.opt_flag(
- 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.
Assignment Branch Condition size for remote_list is too high. [33.78/15] Open
def remote_list
if cli[:ncbi_list_json] && File.size?(cli[:ncbi_list_json])
return read_ncbi_list_json(cli[:ncbi_list_json])
end
- 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. [20/10] Open
def remote_list
if cli[:ncbi_list_json] && File.size?(cli[:ncbi_list_json])
return read_ncbi_list_json(cli[:ncbi_list_json])
end
- 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. [17/10] Open
def parse_reports_as_datasets(reports)
ds = {}
reports.each do |r|
asm = r[:accession]
next if asm.nil? || asm.empty? || asm == '-'
- 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. [17/10] Open
def cli_task_flags(opt)
cli.opt_flag(
opt, 'reference',
'Download all reference genomes (ignore any other status)'
)
- 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. [13/10] Open
def read_ncbi_list_json(file)
cli.say "Reusing remote list: #{file}"
list = {}
n_tot = nil
File.open(file, 'r') do |fh|
- 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 cli_task_flags is too high. [17.72/15] Open
def cli_task_flags(opt)
cli.opt_flag(
opt, 'reference',
'Download all reference genomes (ignore any other status)'
)
- 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 read_ncbi_list_json is too high. [17.72/15] Open
def read_ncbi_list_json(file)
cli.say "Reusing remote list: #{file}"
list = {}
n_tot = nil
File.open(file, 'r') do |fh|
- 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. [12/10] Open
def remote_list_query
q = { taxons: [cli[:taxon]], filters: {} }
if cli[:reference]
q[:filters][:reference_only] = true
else
- 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 parse_reports_as_datasets is too high. [16.16/15] Open
def parse_reports_as_datasets(reports)
ds = {}
reports.each do |r|
asm = r[:accession]
next if asm.nil? || asm.empty? || asm == '-'
- 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 remote_list is too high. [7/6] Open
def remote_list
if cli[:ncbi_list_json] && File.size?(cli[:ncbi_list_json])
return read_ncbi_list_json(cli[:ncbi_list_json])
end
- 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.
Assignment Branch Condition size for write_ncbi_list_json is too high. [15.3/15] Open
def write_ncbi_list_json(file, list)
cli.say "Saving remote list: #{file}"
File.open(file, 'w') do |fh|
fh.puts('# %i' % list.size)
kk = 0
- 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 remote_list
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def remote_list
if cli[:ncbi_list_json] && File.size?(cli[:ncbi_list_json])
return read_ncbi_list_json(cli[:ncbi_list_json])
end
- 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 parse_reports_as_datasets
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def parse_reports_as_datasets(reports)
ds = {}
reports.each do |r|
asm = r[:accession]
next if asm.nil? || asm.empty? || asm == '-'
- 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
Redundant return
detected. Open
return list
- Read upRead up
- Create a ticketCreate a ticket
- 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.
Prefer annotated tokens (like %<foo>s</foo>
) over unannotated tokens (like %s
). Open
fh.puts('# %i' % list.size)
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Use a consistent style for named format string tokens.
Note:
unannotated
style cop only works for strings
which are passed as arguments to those methods:
sprintf
, format
, %
.
The reason is that unannotated format is very similar
to encoded URLs or Date/Time formatting strings.
Example: EnforcedStyle: annotated (default)
# bad
format('%{greeting}', greeting: 'Hello')
format('%s', 'Hello')
# good
format('%<greeting>s', greeting: 'Hello')</greeting>
Example: EnforcedStyle: template
# bad
format('%<greeting>s', greeting: 'Hello')
format('%s', 'Hello')
# good
format('%{greeting}', greeting: 'Hello')</greeting>
Example: EnforcedStyle: unannotated
# bad
format('%<greeting>s', greeting: 'Hello')
format('%{greeting}', 'Hello')
# good
format('%s', 'Hello')</greeting>
Prefer single-quoted strings when you don't need string interpolation or special symbols. Open
cli.say "Obtaining remote list of datasets"
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
Checks if uses of quotes match the configured preference.
Example: EnforcedStyle: single_quotes (default)
# bad
"No special symbols"
"No string interpolation"
"Just text"
# good
'No special symbols'
'No string interpolation'
'Just text'
"Wait! What's #{this}!"
Example: EnforcedStyle: double_quotes
# bad
'Just some text'
'No special chars or interpolation'
# good
"Just some text"
"No special chars or interpolation"
"Every string in #{project} uses double_quotes"
Prefer to_s
over string interpolation. Open
acc = "#{asm}"
- Read upRead up
- Create a ticketCreate a ticket
- 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