bio-miga/miga

View on GitHub

Showing 179 of 1,602 total issues

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

  def clean_fasta_file(file)
    tmp_fh = nil
    tmp_path = nil
    begin
      if file =~ /\.gz/
Severity: Minor
Found in lib/miga/common/format.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 declare_alive_loop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def declare_alive_loop(pid = Process.ppid)
    i = -1
    loop do
      i += 1
      return :no_home unless Dir.exist? daemon_home
Severity: Minor
Found in lib/miga/common/with_daemon.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_cds has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  def check_cds(cli)
    cli.say 'Looking for unzipped genes or proteins'
    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 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 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 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 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 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 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 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 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 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 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

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

Method save_entry has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def save_entry(name, body, p)
    cli.say "  Locating remote dataset: #{name}"
    body[:md][:metadata_only] = true if cli[:only_md]
    rd = MiGA::RemoteDataset.new(body[:ids], body[:db], body[:universe])
    if cli[:get_md]
Severity: Minor
Found in lib/miga/cli/action/download/base.rb - About 55 mins 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 format_result_stats has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def format_result_stats(res)
    res.stats.map do |k, v|
      v = [v, ''] unless v.is_a? Array
      v[0] = ('%.3g' % v[0]) if v[0].is_a? Float
      "<b>#{format_name(k)}:</b> #{v[0]}#{v[1]}<br/>"
Severity: Minor
Found in lib/miga/cli/action/browse.rb - About 55 mins 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

Severity
Category
Status
Source
Language