bio-miga/miga

View on GitHub
lib/miga/dataset/result/add.rb

Summary

Maintainability
A
3 hrs
Test Coverage
B
84%

Module has too many lines. [217/100]
Open

module MiGA::Dataset::Result::Add
  ##
  # Add result type +:raw_reads+ at +base+ (no +_opts+ supported)
  def add_result_raw_reads(base, _opts)
    return nil unless result_files_exist?(base, '.1.fastq')
Severity: Minor
Found in lib/miga/dataset/result/add.rb by rubocop

This cop checks if the length a module exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

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

  def add_result_mytaxa_scan(base, _opts)
    if nonmulti?
      return nil unless
        result_files_exist?(base, %w[.pdf .mytaxa]) ||
        result_files_exist?(base, '.nomytaxa.txt')
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. [20/10]
Open

  def add_result_mytaxa(base, _opts)
    if multi?
      return nil unless
        result_files_exist?(base, '.mytaxa') ||
        result_files_exist?(base, '.nomytaxa.txt')
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. [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 has too many lines. [17/10]
Open

  def add_result_cds(base, opts)
    return nil unless result_files_exist?(base, %w[.faa])

    r = 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. [14/10]
Open

  def add_result_distances_nonref(base)
    return nil unless
      result_files_exist?(base, %w[.aai-medoids.tsv .aai.db]) ||
      result_files_exist?(base, %w[.ani-medoids.tsv .ani.db])

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. [14/10]
Open

  def add_result_assembly(base, opts)
    return nil unless result_files_exist?(base, '.LargeContigs.fna')

    r = 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. [12/10]
Open

  def add_result_trimmed_reads(base, _opts)
    return nil unless result_files_exist?(base, '.1.clipped.fastq')

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

  def add_result_cds(base, opts)
    return nil unless result_files_exist?(base, %w[.faa])

    r = add_files_to_ds_result(
      MiGA::Result.new("#{base}.json"), name,
Severity: Minor
Found in lib/miga/dataset/result/add.rb - About 45 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 add_result_ssu has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
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 - About 35 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 add_result_mytaxa has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def add_result_mytaxa(base, _opts)
    if multi?
      return nil unless
        result_files_exist?(base, '.mytaxa') ||
        result_files_exist?(base, '.nomytaxa.txt')
Severity: Minor
Found in lib/miga/dataset/result/add.rb - About 25 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 add_result_mytaxa_scan has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def add_result_mytaxa_scan(base, _opts)
    if nonmulti?
      return nil unless
        result_files_exist?(base, %w[.pdf .mytaxa]) ||
        result_files_exist?(base, '.nomytaxa.txt')
Severity: Minor
Found in lib/miga/dataset/result/add.rb - About 25 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 add_result_assembly has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def add_result_assembly(base, opts)
    return nil unless result_files_exist?(base, '.LargeContigs.fna')

    r = add_files_to_ds_result(
      MiGA::Result.new("#{base}.json"), name,
Severity: Minor
Found in lib/miga/dataset/result/add.rb - About 25 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

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      add_files_to_ds_result(
        MiGA::Result.new("#{base}.json"), name,
        nomytaxa: '.nomytaxa.txt',
        mytaxa: '.mytaxa',
        report: '.pdf',
Severity: Minor
Found in lib/miga/dataset/result/add.rb and 1 other location - About 25 mins to fix
lib/miga/dataset/result/add.rb on lines 165..177

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

      add_files_to_ds_result(
        MiGA::Result.new("#{base}.json"), name,
        mytaxa: '.mytaxa',
        blast: '.blast',
        mytaxain: '.mytaxain',
Severity: Minor
Found in lib/miga/dataset/result/add.rb and 1 other location - About 25 mins to fix
lib/miga/dataset/result/add.rb on lines 191..204

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 30.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Missing top-level module documentation comment.
Open

module MiGA::Dataset::Result::Add
Severity: Minor
Found in lib/miga/dataset/result/add.rb by rubocop

This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

Example:

# bad
class Person
  # ...
end

# good
# Description/Explanation of Person class
class Person
  # ...
end

There are no issues that match your filters.

Category
Status