Showing 838 of 1,651 total issues
Method has too many lines. [25/10] Open
def parse_cli
cli.opt_common = false
cli.parse do |opt|
descriptions = cli.class.TASK_DESC.keep_if { |k, v| k != :generic }
opt.separator MiGA::MiGA.tabulate(
- 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_gtdb_alt_taxonomy is too high. [29.15/15] Open
def test_gtdb_alt_taxonomy
declare_remote_access
rd = MiGA::RemoteDataset.new('GCA_018200315.1', :assembly, :gtdb)
rd.metadata[:get_ncbi_taxonomy] = true
md = rd.get_metadata
- 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_generic_transfer is too high. [29.07/15] Open
def test_generic_transfer
hello = File.expand_path('Hello', tmpdir)
world = File.expand_path('World', tmpdir)
assert_respond_to(File, :generic_transfer)
FileUtils.touch(hello)
- 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_result_source is too high. [29.07/15] Open
def test_result_source
r = dataset.add_result(:trimmed_reads)
assert_equal(dataset.name, r.source.name)
assert_equal(:trimmed_reads, r.key)
assert_equal('data/02.trimmed_reads', r.relative_dir)
- 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 daemon_loop is too high. [29.43/15] Open
def daemon_loop
l_say(3, 'Daemon loop start')
reload_project
check_datasets or check_project
if shutdown_when_done? && (jobs_running.size + jobs_to_run.size).zero?
- 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. [24/10] Open
def job_cmd(to_run)
what = to_run[:ds].nil? ? :project : :dataset
vars = {
'PROJECT' => project.path,
'RUNTYPE' => runopts_for(:type, what),
- 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 get_ncbi_taxonomy is too high. [29.56/15] Open
def get_ncbi_taxonomy
tax_id = get_ncbi_taxid or return
if self.class.ncbi_taxonomy_dump?
return self.class.taxonomy_from_ncbi_dump(tax_id)
- 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 load_status is too high. [29.88/15] Open
def load_status
f_path = File.join(daemon_home, 'status.json')
return unless File.size? f_path
say 'Loading previous status in daemon/status.json:'
- 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. [24/10] Open
def parse_cli
cli.defaults = { threads: 1 }
cli.defaults = Hash[@@OPERATIONS.keys.map { |i| [i, true] }]
cli.parse do |opt|
operation_n = Hash[@@OPERATIONS.map { |k, v| [v[0], k] }]
- 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. [24/10] Open
def parse_cli
cli.parse do |opt|
cli.opt_object(opt, %i[project dataset_opt])
opt.on(
'-k', '--key STRING',
- 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_cli is too high. [29.73/15] Open
def parse_cli
cli.interactive = true
cli.defaults = {
mytaxa: nil,
rdp: 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 download_entries
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def download_entries(ds, p)
cli.say "Downloading #{ds.size} " + (ds.size == 1 ? 'entry' : 'entries')
p.do_not_save = true if cli[:save_every] != 1
ignore = !cli[:ignore_until].nil?
downloaded = 0
- 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 traverse_taxonomy
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def traverse_taxonomy(tab, dist)
cli.say 'Traversing taxonomy'
rank_i = 0
Taxonomy.KNOWN_RANKS.each do |rank|
next if rank == :ns
- 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. [23/10] Open
def test_get
hiv2 = 'M30502.1'
{ embl: :ebi, nuccore: :ncbi }.each do |db, universe|
rd = MiGA::RemoteDataset.new(hiv2, db, universe)
assert_equal([hiv2], rd.ids)
- 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_daemon_operations is too high. [28.28/15] Open
def test_daemon_operations
d = TestWithDaemon.new(tmpdir)
FileUtils.touch(d.output_file)
assert_not_predicate(d, :active?)
- 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. [23/10] Open
def test_project_result_hooks
$res = :test
$counter = 1
project.add_hook(
:on_result_ready,
- 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 advance is too high. [20/7] Open
def advance(step, n = 0, total = nil, bin = true)
# Initialize advance timing
@_advance_time ||= { last: nil, n: 0, avg: nil, total: total }
if @_advance_time[:n] > n || total != @_advance_time[:total]
@_advance_time[:last] = nil
- 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
Cyclomatic complexity for seqs_length is too high. [19/6] Open
def seqs_length(file, format, opts = {})
opts[:gc] = true if opts[:skew]
fh = file =~ /\.gz/ ? Zlib::GzipReader.open(file) : File.open(file, 'r')
l = []
gc = 0
- 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.
Perceived complexity for run_cmd is too high. [20/7] Open
def run_cmd(cmd, opts = {})
opts = run_cmd_opts(opts)
cmd = cmd.shelljoin if cmd.is_a?(Array)
spawn_opts = {}
spawn_opts[:out] = opts[:stdout] if opts[:stdout]
- 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
Assignment Branch Condition size for add_metadata is too high. [28.64/15] Open
def add_metadata(obj, cli = self)
raise "Unsupported object: #{obj.class}" unless obj.respond_to? :metadata
(cli[:metadata] || '').split(',').each do |pair|
(k, v) = pair.split('=')
- 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