GlobalNamesArchitecture/taxamatch_rb

View on GitHub
lib/taxamatch_rb/base.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method match_authors has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def match_authors(preparsed_1, preparsed_2)
      p1 = { normalized_authors: [], years: [] }
      p2 = { normalized_authors: [], years: [] }
      if preparsed_1[:infraspecies] || preparsed_2[:infraspecies]
        p1 = preparsed_1[:infraspecies].last if preparsed_1[:infraspecies]
Severity: Minor
Found in lib/taxamatch_rb/base.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 match_multinomial has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def match_multinomial(preparsed_1, preparsed_2)
      gen_match = match_genera(preparsed_1[:genus], preparsed_2[:genus])
      sp_match = match_species(preparsed_1[:species], preparsed_2[:species])
      total_length = preparsed_1[:genus][:string].size +
        preparsed_2[:genus][:string].size +
Severity: Minor
Found in lib/taxamatch_rb/base.rb - About 1 hr to fix

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

        def match_species(sp1, sp2, opts = {})
          sp1_length = sp1[:normalized].size
          sp2_length = sp2[:normalized].size
          opts = { with_phonetic_match: true }.merge(opts)
          min_length = [sp1_length, sp2_length].min
    Severity: Minor
    Found in lib/taxamatch_rb/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 match_multinomial has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def match_multinomial(preparsed_1, preparsed_2)
          gen_match = match_genera(preparsed_1[:genus], preparsed_2[:genus])
          sp_match = match_species(preparsed_1[:species], preparsed_2[:species])
          total_length = preparsed_1[:genus][:string].size +
            preparsed_2[:genus][:string].size +
    Severity: Minor
    Found in lib/taxamatch_rb/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 match_matches has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def match_matches(genus_match, species_match, infraspecies_match = nil)
          match = species_match
          if infraspecies_match
            match['edit_distance'] += infraspecies_match['edit_distance']
            match['match'] &&= infraspecies_match['match']
    Severity: Minor
    Found in lib/taxamatch_rb/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

    Consider simplifying this complex logical expression.
    Open

          match = true if ed <= 4 &&
            (min_length >= ed * 2) &&
            (ed < 2 || sp1[:normalized][0] == sp2[:normalized][0]) &&
            (ed < 4 || sp1[:normalized][0...3] == sp2[:normalized][0...3])
    Severity: Major
    Found in lib/taxamatch_rb/base.rb - About 40 mins to fix

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

          def match_genera(genus1, genus2, opts = {})
            genus1_length = genus1[:normalized].size
            genus2_length = genus2[:normalized].size
            opts = { with_phonetic_match: true }.merge(opts)
            min_length = [genus1_length, genus2_length].min
      Severity: Minor
      Found in lib/taxamatch_rb/base.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 taxamatch_preparsed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def taxamatch_preparsed(preparsed_1, preparsed_2)
            result = nil
            if preparsed_1[:uninomial] && preparsed_2[:uninomial]
              result =  match_uninomial(preparsed_1, preparsed_2)
            end
      Severity: Minor
      Found in lib/taxamatch_rb/base.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

      There are no issues that match your filters.

      Category
      Status