wurmlab/GeneValidator

View on GitHub
lib/genevalidator/validation_gene_merge.rb

Summary

Maintainability
C
1 day
Test Coverage
A
97%

Method run has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def run
      raise NotEnoughHitsError if hits.length < opt[:min_blast_hits]
      raise unless prediction.is_a?(Query) && hits[0].is_a?(Query)

      start = Time.now
Severity: Minor
Found in lib/genevalidator/validation_gene_merge.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 run has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def run
      raise NotEnoughHitsError if hits.length < opt[:min_blast_hits]
      raise unless prediction.is_a?(Query) && hits[0].is_a?(Query)

      start = Time.now
Severity: Minor
Found in lib/genevalidator/validation_gene_merge.rb - About 1 hr to fix

    Method unimodality_test has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def unimodality_test(xx, yy)
          mean_x = xx.mean
          median_x = xx.median
          mode_x = xx.mode
          sd_x = xx.standard_deviation
    Severity: Minor
    Found in lib/genevalidator/validation_gene_merge.rb - About 1 hr to fix

      Method conclude has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def conclude
            if @unimodality
              'This suggest that the query sequence represents a single gene.'
            else
              diff = @result == :yes ? ' within' : ' outside'
      Severity: Minor
      Found in lib/genevalidator/validation_gene_merge.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 initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def initialize(short_header, header, description, slope, unimodality,
                         expected = :no)
      Severity: Minor
      Found in lib/genevalidator/validation_gene_merge.rb - About 45 mins to fix

        Consider simplifying this complex logical expression.
        Open

              if cond1_x && cond2_x && cond3_x && cond1_y && cond2_y && cond3_y
                true
              else
                false
              end
        Severity: Major
        Found in lib/genevalidator/validation_gene_merge.rb - About 40 mins to fix

          Method unimodality_test has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def unimodality_test(xx, yy)
                mean_x = xx.mean
                median_x = xx.median
                mode_x = xx.mode
                sd_x = xx.standard_deviation
          Severity: Minor
          Found in lib/genevalidator/validation_gene_merge.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

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

                if sd_y == 0
                  cond1_y = true
                  cond2_y = true
                  cond3_y = true
                else
          Severity: Major
          Found in lib/genevalidator/validation_gene_merge.rb and 1 other location - About 1 hr to fix
          lib/genevalidator/validation_gene_merge.rb on lines 308..315

          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 51.

          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

                if sd_x == 0
                  cond1_x = true
                  cond2_x = true
                  cond3_x = true
                else
          Severity: Major
          Found in lib/genevalidator/validation_gene_merge.rb and 1 other location - About 1 hr to fix
          lib/genevalidator/validation_gene_merge.rb on lines 323..330

          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 51.

          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

          There are no issues that match your filters.

          Category
          Status