bio-miga/miga

View on GitHub

Showing 186 of 1,651 total issues

Method ncbi_asm_acc2id has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def ncbi_asm_acc2id(acc, retrials = 3)
      return acc if acc =~ /^\d+$/

      search_doc = MiGA::Json.parse(
        download(:ncbi_search, :assembly, acc, :json),
Severity: Minor
Found in lib/miga/remote_dataset.rb - About 1 hr 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 compute_stats_cds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def compute_stats_cds
    s = MiGA::MiGA.seqs_length(file_path(:proteins), :fasta)
    stats = {
      predicted_proteins: s[:n],
      average_length: [s[:avg], 'aa']
Severity: Minor
Found in lib/miga/result/stats.rb - About 1 hr 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 read_distances has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def read_distances
    p = cli.load_project
    cli[:metric] ||= p.clade? ? 'ani' : 'aai'
    res_n = "#{cli[:metric]}_distances"
    cli.say "Reading distances: 1-#{cli[:metric].upcase}"
Severity: Minor
Found in lib/miga/cli/action/tax_dist.rb - About 1 hr 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_ess has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
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?
Severity: Minor
Found in lib/miga/cli/action/doctor/operations.rb - About 1 hr 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 opts_for_wf has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def opts_for_wf(opt, files_desc, params = {})
    {
      multi: false, cleanup: true, project_type: false, ncbi: true, qual: true
    }.each { |k, v| params[k] = v if params[k].nil? }
    opt.on(
Severity: Minor
Found in lib/miga/cli/action/wf.rb - About 1 hr 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_files has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def check_files(cli)
    cli.say 'Looking for outdated files in results'
    n, k = cli.load_project.dataset_names.size, 0
    cli.load_project.each_dataset do |d|
      cli.advance('Datasets:', k += 1, n, false)
Severity: Minor
Found in lib/miga/cli/action/doctor/operations.rb - About 1 hr 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 find_software has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
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 - About 1 hr 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 27 lines of code (exceeds 25 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 1 hr to fix

Method ncbi_asm_json_doc has 27 lines of code (exceeds 25 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 1 hr to fix

Method use_ncbi_taxonomy_dump has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def use_ncbi_taxonomy_dump(path, cli = nil)
      raise "Directory doesn't exist: #{path}" unless File.directory?(path)

      # Structure: { TaxID => ["name", "rank", parent TaxID] }
      MiGA::MiGA.DEBUG "Loading NCBI Taxonomy dump: #{path}"
Severity: Minor
Found in lib/miga/remote_dataset.rb - About 1 hr to fix

Method test_preprocessing has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def test_preprocessing
    p1 = project
    assert_predicate(p1, :done_preprocessing?)
    d1 = p1.add_dataset('BAH')
    assert_not_predicate(p1, :done_preprocessing?)
Severity: Minor
Found in test/project_test.rb - About 1 hr to fix

Method merge_bidir_tmp has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def merge_bidir_tmp(tmp)
    tmp_done = File.join(tmp, 'chunks.txt')
    chunks = File.readlines(tmp_done)[0].chomp.to_i

    lower_tr = []
Severity: Minor
Found in lib/miga/cli/action/doctor/distances.rb - About 1 hr to fix

Method get_files_and_type has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def get_files_and_type
    files = cli.files
    file_type = nil
    if files.empty?
      cli.ensure_par({ dataset: '-D' },
Severity: Minor
Found in lib/miga/cli/action/add.rb - About 1 hr to fix

Method parse has 26 lines of code (exceeds 25 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 1 hr to fix

Method add_metadata has 26 lines of code (exceeds 25 allowed). Consider refactoring.
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('=')
Severity: Minor
Found in lib/miga/cli/objects_helper.rb - About 1 hr to fix

Method parse_cli has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse_cli
    cli.defaults = { metric: :aai, external: false, how_many: 5 }
    cli.parse do |opt|
      cli.opt_object(opt, [:project, :dataset_opt])
      cli.opt_filter_datasets(opt)
Severity: Minor
Found in lib/miga/cli/action/relatives.rb - About 1 hr to fix

Method perform has 26 lines of code (exceeds 25 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 1 hr to fix

Method test_check_datasets has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def test_check_datasets
    p = project
    d = daemon
    d.runopts(:maxjobs, 0, true)
    assert_empty(d.jobs_to_run)
Severity: Minor
Found in test/daemon_test.rb - About 1 hr to fix

Method ncbi_asm_get has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def ncbi_asm_get(opts)
      require 'tempfile'
      require 'zip'

      zipped = download(
Severity: Minor
Found in lib/miga/remote_dataset/download.rb - About 1 hr to fix

Method perform has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perform
    cli.ensure_par(result: '-r')
    ds = cli.load_and_filter_datasets
    cli.say 'Loading results'
    k = 0
Severity: Minor
Found in lib/miga/cli/action/summary.rb - About 1 hr to fix
Severity
Category
Status
Source
Language