bio-miga/miga

View on GitHub

Showing 1,599 of 1,613 total issues

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
Severity: Minor
Found in lib/miga/remote_dataset.rb by rubocop

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]
Confirmed

  def get_metadata(metadata_def = {})
    metadata_def.each { |k, v| @metadata[k] = v }
    return @metadata if @metadata[:bypass_metadata]

    case universe
Severity: Minor
Found in lib/miga/remote_dataset.rb by rubocop

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)
Severity: Minor
Found in lib/miga/common/net.rb by rubocop

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 option_from_string(key, value)
    opt = assert_has_option(key)

    if ['', 'nil'].include?(value)
      nil
Severity: Minor
Found in lib/miga/common/with_option.rb by rubocop

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
    ]
Severity: Minor
Found in lib/miga/cli/action/lair.rb by rubocop

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_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')

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 perform is too high. [23.02/15]
Open

  def perform
    # Input data
    norun = %w[
      project_stats haai_distances aai_distances ani_distances clade_finding
    ]
Severity: Minor
Found in lib/miga/cli/action/quality_wf.rb by rubocop

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'
    )

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'
Severity: Minor
Found in lib/miga/cli/action/wf.rb by rubocop

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. [23.41/15]
Open

  def parse_cli
    default_opts_for_wf
    cli.defaults = {
      metric: :ani, threshold: 95.0, criterion: :quality,
      summaries: true, collection: true
Severity: Minor
Found in lib/miga/cli/action/derep_wf.rb by rubocop

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 find_software(exec)
    path = nil
    loop do
      d_path = File.dirname(run_cmd(cli, ['which', exec], raise: false))
      if cli[:ask] || d_path == '.'
Severity: Minor
Found in lib/miga/cli/action/init.rb by rubocop

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)
Severity: Minor
Found in lib/miga/cli/action/db.rb by rubocop

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(
Severity: Minor
Found in lib/miga/dataset/result/add.rb by rubocop

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 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
Severity: Minor
Found in lib/miga/remote_dataset.rb - About 2 hrs to fix

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_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?
Severity: Minor
Found in lib/miga/cli/action/doctor/operations.rb - About 2 hrs to fix

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 perform has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

  def perform
    unless cli[:value].nil?
      cli.ensure_par(
        { key: '-k' },
        '%<name>s is mandatory when --value is set: provide %<flag>s'
Severity: Minor
Found in lib/miga/cli/action/option.rb - About 2 hrs to fix

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 has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def parse(path, opts = {})
      opts = default_opts(opts)

      # Read JSON
      cont = path
Severity: Minor
Found in lib/miga/json.rb - About 2 hrs to fix

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_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|
Severity: Minor
Found in lib/miga/cli/action/doctor/distances.rb - About 2 hrs to fix

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

Class DaemonTest has 23 methods (exceeds 20 allowed). Consider refactoring.
Open

class DaemonTest < Test::Unit::TestCase
  include TestHelper
  include DaemonHelper

  def setup
Severity: Minor
Found in test/daemon_test.rb - About 2 hrs to fix

Assignment Branch Condition size for test_daemmon_status is too high. [22.36/15]
Open

  def test_daemmon_status
    d = TestWithDaemon.new(tmpdir)
    out = capture_stdout { d.status }.string
    assert_match(/Not running/, out)

Severity: Minor
Found in test/with_daemon_test.rb by rubocop

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

Severity
Category
Status
Source
Language