SpeciesFileGroup/taxonworks

View on GitHub
lib/batch_load/column_resolver.rb

Summary

Maintainability
C
1 day
Test Coverage

Method otu has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def otu(columns)
      r = BatchLoad::ColumnResolver::Result.new

      if columns['otu_id']
        begin
Severity: Minor
Found in lib/batch_load/column_resolver.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 geographic_area has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def geographic_area(columns, data_origin = nil)
      r = BatchLoad::ColumnResolver::Result.new

      if columns['geographic_area_id']
        begin
Severity: Minor
Found in lib/batch_load/column_resolver.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 source has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def source(columns)
      r = BatchLoad::ColumnResolver::Result.new

      if columns['source_id']
        begin
Severity: Minor
Found in lib/batch_load/column_resolver.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 otu has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def otu(columns)
      r = BatchLoad::ColumnResolver::Result.new

      if columns['otu_id']
        begin
Severity: Minor
Found in lib/batch_load/column_resolver.rb - About 1 hr to fix

    Method geographic_area has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def geographic_area(columns, data_origin = nil)
          r = BatchLoad::ColumnResolver::Result.new
    
          if columns['geographic_area_id']
            begin
    Severity: Minor
    Found in lib/batch_load/column_resolver.rb - About 1 hr to fix

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

          def data_attribute(columns, type = 'import')
            r = BatchLoad::ColumnResolver::Result.new
      
            predicate = columns['predicate']
            value = columns['value']
      Severity: Minor
      Found in lib/batch_load/column_resolver.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

      Avoid deeply nested control flow statements.
      Open

              if list.blank? # treat it like a taxon name
                list = Otu.joins(:taxon_name)
                           .where(taxon_names: {cached: name}, project_id: proj_id)
                           .limit(2)
              end
      Severity: Major
      Found in lib/batch_load/column_resolver.rb - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                r.error_messages << "Multiple OTUs matched the name '#{name}'." if r.multiple_matches?
        Severity: Major
        Found in lib/batch_load/column_resolver.rb - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                  r.error_messages << "No OTU with name '#{name}' exists." if r.no_matches?
          Severity: Major
          Found in lib/batch_load/column_resolver.rb - About 45 mins to fix

            Method collection_object_by_identifier has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                def collection_object_by_identifier(columns)
                  r = BatchLoad::ColumnResolver::Result.new
            
                  # find a namespace (ns1) with a short_name of row[headers[0]] (id1)
                  # find a collection_object which has an identifier which has a namespace (ns1), and a cached of
            Severity: Minor
            Found in lib/batch_load/column_resolver.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

            There are no issues that match your filters.

            Category
            Status