Showing 838 of 1,651 total issues
Assignment Branch Condition size for test_terminate is too high. [23.02/15] Open
def test_terminate
d = daemon
assert_not_predicate(d, :active?)
assert_path_not_exist(d.alive_file)
assert_path_not_exist(d.terminated_file)
- 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. [18/10] Open
def test_aai_pvalues
distant_intax = MiGA::TaxDist.aai_pvalues(35.0, :intax)
assert_lt(distant_intax[:root], 0.05)
assert_gt(distant_intax[:g], 0.05)
assert_nil(distant_intax[:ns])
- 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_options is too high. [23.02/15] Open
def test_options
d1 = daemon
assert_respond_to(d1, :default_options)
assert_equal(:normal, d1.default_options[:dir_mode])
assert_equal(2, d1.runopts(:latency))
- 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 test_dataset_result_hooks is too high. [23.54/15] Open
def test_dataset_result_hooks
$res = :test
$counter = 1
dataset.add_hook(:on_result_ready, :run_lambda, Proc.new { |r| $res = r })
dataset.add_hook(
- 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 test_load is too high. [23.19/15] Open
def test_load
md1 = MiGA::Metadata.new(tmpfile('md_load.json'), { t: 1 })
assert_equal(1, md1[:t])
declare_forks
- 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. [18/10] Confirmed
def get_metadata(metadata_def = {})
metadata_def.each { |k, v| @metadata[k] = v }
return @metadata if @metadata[:bypass_metadata]
case universe
- 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.
Perceived complexity for ncbi_asm_json_doc is too high. [15/7] Open
def ncbi_asm_json_doc
return @_ncbi_asm_json_doc unless @_ncbi_asm_json_doc.nil?
if db == :assembly && %i[ncbi gtdb seqcode].include?(universe)
metadata[:ncbi_asm] ||= ids.first
- 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. [18/10] Open
def option_from_string(key, value)
opt = assert_has_option(key)
if ['', 'nil'].include?(value)
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. [18/10] Open
def download_file_ftp(connection, file = nil, target = nil)
# Open connection unless passed
close_conn = false
if connection.is_a?(String) || connection.is_a?(Symbol) ||
connection.is_a?(URI)
- 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. [18/10] Open
def perform
cli.ensure_par(path: '-p')
k_opts = %i[
json latency wait_for keep_inactive trust_timestamp name dry exclude
]
- 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 perform is too high. [23.02/15] Open
def perform
# Input data
norun = %w[
project_stats haai_distances aai_distances ani_distances clade_finding
]
- 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_mytaxa_database is too high. [23.62/15] Open
def check_mytaxa_database(paths)
cli.print 'Looking for MyTaxa DB... '
mt = File.dirname(paths['MyTaxa'])
dmnd_db = 'AllGenomes.faa.dmnd'
miga_db = File.join(ENV['MIGA_HOME'], '.miga_db')
- 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 configure_ssh_daemon is too high. [23.41/15] Open
def configure_ssh_daemon(v)
v[:latency] = cli.ask_user('How long should I sleep? (in secs)', '3').to_i
v[:nodelist] = cli.ask_user(
'What environmental variable points to node list?', '$MIGA_NODELIST'
)
- 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. [23.41/15] Open
def parse_cli
default_opts_for_wf
cli.defaults = {
metric: :ani, threshold: 95.0, criterion: :quality,
summaries: true, collection: true
- 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. [18/10] 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 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. [18/10] Open
def find_software(exec)
path = nil
loop do
d_path = File.dirname(run_cmd(cli, ['which', exec], raise: false))
if cli[:ask] || d_path == '.'
- 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. [18/10] Open
def check_digest(ver, file)
cli.say 'Checking MD5 digest'
cli.say "Expected: #{ver[:MD5]}"
md5 = Digest::MD5.new
size = File.size(file)
- 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. [18/10] Open
def add_result_ssu(base, opts)
return MiGA::Result.new("#{base}.json") if result(:assembly).nil?
return nil unless result_files_exist?(base, '.ssu.fa')
r = add_files_to_ds_result(
- 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_db
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def check_db(cli)
cli.say 'Checking integrity of databases'
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
Method ncbi_asm_json_doc
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def ncbi_asm_json_doc
return @_ncbi_asm_json_doc unless @_ncbi_asm_json_doc.nil?
if db == :assembly && %i[ncbi gtdb seqcode].include?(universe)
metadata[:ncbi_asm] ||= ids.first
- 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"