bio-miga/miga

View on GitHub

Showing 838 of 1,651 total issues

Assignment Branch Condition size for list_databases is too high. [16.03/15]
Open

  def list_databases(manif)
    return false unless cli[:list_databases]

    cli.puts "# Recommended database: #{manif[:recommended]}"
    cli.puts ''
Severity: Minor
Found in lib/miga/cli/action/db.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. [11/10]
Open

  def add_result_trimmed_fasta(base, _opts)
    return nil unless
      result_files_exist?(base, '.CoupledReads.fa') ||
      result_files_exist?(base, '.SingleReads.fa')  ||
      result_files_exist?(base, %w[.1.fasta .2.fasta])
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 has too many lines. [11/10]
Open

  def closest_relatives(how_many = 1, ref_project = false, metric = :aai)
    return nil if multi?

    r = result(ref_project ? :taxonomy : :distances)
    return nil if r.nil?
Severity: Minor
Found in lib/miga/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. [11/10]
Open

  def add_result_essential_genes(base, _opts)
    return nil unless result_files_exist?(base, %w[.ess.faa .ess .ess/log])

    add_files_to_ds_result(
      MiGA::Result.new("#{base}.json"), name,
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 has too many lines. [11/10]
Open

    def download(*params)
      opts = download_opts(*params)
      doc = send(opts[:_fun], opts)

      unless opts[:file].nil?
Severity: Minor
Found in lib/miga/remote_dataset/download.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. [11/10]
Open

  def check_type
    raise MiGA::Error.new('Undefined dataset type') unless type
    return false if type == :empty

    unless self.class.KNOWN_TYPES[type]
Severity: Minor
Found in lib/miga/dataset/type.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 opt_common is too high. [16.55/15]
Open

  def opt_common(opt)
    return unless @opt_common

    if interactive
      opt.on(
Severity: Minor
Found in lib/miga/cli/opt_helper.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

Cyclomatic complexity for ignore_by_type? is too high. [7/6]
Open

  def ignore_by_type?(task, type)
    return false if force_task?(task)

    test, list =
      case type.to_sym
Severity: Minor
Found in lib/miga/dataset/result/ignore.rb by rubocop

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.

Method has too many lines. [11/10]
Open

    def download_opts(
          universe, db, ids, format, file = nil, extra = {}, obj = nil)
      universe_hash = @@UNIVERSE[universe]
      database_hash = universe_hash.dig(:dbs, db)
      getter = database_hash[:getter] || :download
Severity: Minor
Found in lib/miga/remote_dataset/download.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 parse_cli has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def parse_cli
    cli.defaults = { info: false, processing: false, silent: 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/ls.rb - About 1 hr to fix

Method run_cmd has 44 lines of code (exceeds 25 allowed). Consider refactoring.
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]
Severity: Minor
Found in lib/miga/common/system_call.rb - About 1 hr to fix

Method each_project has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def each_project(dir = path)
    Dir.entries(dir).each do |f|
      next if %w[. ..].include?(f) # Ruby <= 2.3 doesn't have Dir.children

      f = File.join(dir, f)
Severity: Minor
Found in lib/miga/lair.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 14 (exceeds 5 allowed). Consider refactoring.
Open

  def clean_fasta_file(file, min_len = 1)
    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 unregistered_datasets has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def unregistered_datasets
    datasets = []
    MiGA::Dataset.RESULT_DIRS.values.each do |dir|
      dir_p = "#{path}/data/#{dir}"
      next unless Dir.exist? dir_p
Severity: Minor
Found in lib/miga/project/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 perform has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def perform
    p = cli.load_project
    if !cli[:taxfile].nil?
      cli.say 'Reading tax-file and registering taxonomy'
      tfh = File.open(cli[:taxfile], 'r')
Severity: Minor
Found in lib/miga/cli/action/tax_set.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 perform has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def perform
    p = cli.load_project
    if not cli[:datum].nil?
      v = p.metadata[cli[:datum]]
      cli.puts v.nil? ? '?' : v
Severity: Minor
Found in lib/miga/cli/action/about.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_dist_eval has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def check_dist_eval(cli, p, res)
    y = { notok: Set.new, fix: Set.new }
    Zlib::GzipReader.open(res.file_path(:matrix)) do |fh|
      lineno = 0
      fh.each_line do |ln|
Severity: Minor
Found in lib/miga/cli/action/doctor/base.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 reference_db has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

  def reference_db
    cli.say "Locating reference database"
    ref_db_path = cli[:db_path]
    if ref_db_path.nil?
      if cli[:download]
Severity: Minor
Found in lib/miga/cli/action/classify_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 clean_fasta_file has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def clean_fasta_file(file, min_len = 1)
    tmp_fh = nil
    tmp_path = nil
    begin
      if file =~ /\.gz/
Severity: Minor
Found in lib/miga/common/format.rb - About 1 hr to fix

Assignment Branch Condition size for test_trimmed_fasta is too high. [15.3/15]
Open

  def test_trimmed_fasta
    dir = 'data/04.trimmed_fasta'
    fa = file_path(dir, '.CoupledReads.fa')
    File.open(fa, 'w') { |fh| fh.puts '>1', 'ACTAC' }
    touch_done(dir)
Severity: Minor
Found in test/result_stats_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