Showing 1,637 of 1,651 total issues
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
Method has too many lines. [14/10] Open
def each_file_listed(datasets, &blk)
datasets.each_with_index do |ds, k|
cli.advance('Datasets:', k + 1, datasets.size, false)
# Metadata
blk.call(
- 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. [14/10] Open
def open_rc_file
rc_path = File.expand_path('.miga_rc', ENV['MIGA_HOME'])
if File.exist? rc_path
if cli.ask_user(
'I found a previous configuration. Do you want to continue?',
- 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. [14/10] Open
def check_bidir(cli)
cli.say 'Checking if reference distances are bidirectional'
project = cli.load_project
ref_ds = project.each_dataset.select(&:ref?)
- 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.
Cyclomatic complexity for download_datasets is too high. [10/6] Open
def download_datasets
# Download datasets from NCBI
unless cli[:ncbi_taxon].nil?
what = cli[:ncbi_ref] ? '--reference' :
cli[:ncbi_draft] ? '--all' : '--complete'
- 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 perform is too high. [19.44/15] Open
def perform
p = cli.load_project
ud = p.unregistered_datasets
ud.each do |dn|
cli.puts dn
- 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. [14/10] Open
def format_metadata(obj)
'<table class="table table-sm table-responsive">' +
obj.metadata.data.map do |k, v|
case k
when /^run_/, :plugins, :user
- 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. [14/10] Open
def create_project(stage, p_metadata = {}, d_metadata = {})
cli.ensure_par(
outdir: '-o',
project_type: '--project-type',
dataset_type: '--dataset-type'
- 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. [14/10] Open
def create_remote_dataset(sub_cli, p)
sub_cli.ensure_par(dataset: '-D', ids: '-I')
unless sub_cli[:api_key].nil?
if sub_cli[:universe] == :web && sub_cli[:db] == :assembly_gz
ENV['NCBI_API_KEY'] = sub_cli[:api_key]
- 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 ask_for_optional is too high. [19.34/15] Open
def ask_for_optional(symbol, name)
cli[symbol] = cli[:optional] if !cli[:optional].nil? && cli[symbol].nil?
return cli[symbol] unless cli[symbol].nil?
cli[symbol] =
- 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 parse_cli is too high. [19.92/15] Open
def parse_cli
cli.defaults = { units: false, tabular: false }
cli.parse do |opt|
cli.opt_object(opt, [:project, :dataset_opt])
cli.opt_filter_datasets(opt)
- 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 create_dataset is too high. [19.34/15] Open
def create_dataset(sub_cli, p, rd)
sub_cli.say 'Creating dataset'
if Dataset.exist?(p, sub_cli[:dataset])
raise "Dataset already exists: #{sub_cli[:dataset]}"
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
Perceived complexity for perform is too high. [11/7] Open
def perform
cli.ensure_par(result: '-r')
ds = cli.load_and_filter_datasets
cli.say 'Loading results'
k = 0
- Read upRead up
- Create a ticketCreate a ticket
- Exclude checks
This cop tries to produce a complexity score that's a measure of the
complexity the reader experiences when looking at a method. For that
reason it considers when
nodes as something that doesn't add as much
complexity as an if
or a &&
. Except if it's one of those special
case
/when
constructs where there's no expression after case
. Then
the cop treats it as an if
/elsif
/elsif
... and lets all the when
nodes count. In contrast to the CyclomaticComplexity cop, this cop
considers else
nodes as adding complexity.
Example:
def my_method # 1
if cond # 1
case var # 2 (0.8 + 4 * 0.2, rounded)
when 1 then func_one
when 2 then func_two
when 3 then func_three
when 4..10 then func_other
end
else # 1
do_something until a && b # 2
end # ===
end # 7 complexity points
Method has too many lines. [14/10] Open
def add_result_assembly(base, opts)
return nil unless result_files_exist?(base, '.LargeContigs.fna')
r = add_files_to_ds_result(
MiGA::Result.new("#{base}.json"), name,
- 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.
Cyclomatic complexity for opt_object is too high. [10/6] Open
def opt_object(opt, what = %i[project dataset])
what.each do |w|
case w
when :project
opt.on(
- 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_datasets
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def check_datasets
l_say(2, 'Checking datasets')
o = false
project.each_dataset do |ds|
next unless ds.status == :incomplete
- 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_cli
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def parse_cli
cli.defaults = {
database: :recommended,
version: :latest,
local: File.join(ENV['MIGA_HOME'], '.miga_db'),
- Create a ticketCreate a ticket
Assignment Branch Condition size for test_check_project is too high. [18.11/15] Open
def test_check_project
d1 = daemon(1)
helper_datasets_with_results(1, 1).first.inactivate!
out = capture_stderr { d1.check_project }.string
assert_match(/Queueing miga-project:p/, out)
- 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. [13/10] Open
def test_ncbi_datasets_request
rd = MiGA::RemoteDataset.new({ taxons: 'Bos' }, :genome, :ncbi_datasets)
u = rd.download_uri
h = rd.download_headers
p = rd.download_payload
- 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 test_update_metadata is too high. [18.25/15] Open
def test_update_metadata
declare_remote_access
hiv1 = 'GCF_000856385.1'
d1 = MiGA::Dataset.new(project, 'd1')
assert_nil(d1.metadata[:ncbi_assembly])
- 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