lib/mootiro_importer.rb

Summary

Maintainability
D
1 day
Test Coverage

File mootiro_importer.rb has 343 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module MootiroImporter

  module_function

  REDIS_HOST = ENV['MOOTIRO_REDIS_HOST'] || '10.0.2.2'
Severity: Minor
Found in lib/mootiro_importer.rb - About 4 hrs to fix

    Method build_user has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_user(d, &blk)
        Rails.logger.debug "Building User... "
        user = User.new(
          name: d[:name],
          email: d[:email],
    Severity: Minor
    Found in lib/mootiro_importer.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 build_map has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

      def build_map(d, &blk)
        Rails.logger.debug "Building Map... "
        additional_info = {}
        additional_info.merge! short_description: d[:short_description] unless d[:short_description].blank?
    
    
    Severity: Minor
    Found in lib/mootiro_importer.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 build_map has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def build_map(d, &blk)
        Rails.logger.debug "Building Map... "
        additional_info = {}
        additional_info.merge! short_description: d[:short_description] unless d[:short_description].blank?
    
    
    Severity: Minor
    Found in lib/mootiro_importer.rb - About 1 hr to fix

      Method remove_geometrycollection has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

        def remove_geometrycollection(location)
          Rails.logger.debug "Removing GeometryCollection... "
          return nil if location.eql? 'EMPTY GEOMETRYCOLLECTION'
          return location unless location.include? "GEOMETRYCOLLECTION"
      
      
      Severity: Minor
      Found in lib/mootiro_importer.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 remove_geometrycollection has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        def remove_geometrycollection(location)
          Rails.logger.debug "Removing GeometryCollection... "
          return nil if location.eql? 'EMPTY GEOMETRYCOLLECTION'
          return location unless location.include? "GEOMETRYCOLLECTION"
      
      
      Severity: Minor
      Found in lib/mootiro_importer.rb - About 1 hr to fix

        Method build_relation has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def build_relation(d, &blk)
            Rails.logger.debug "Building Relation... "
            model1 = model_from_oid(d[:oid_1])
            model2 = model_from_oid(d[:oid_2])
            return false unless model1 && model2
        Severity: Minor
        Found in lib/mootiro_importer.rb - About 1 hr to fix

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

            def build_geo_data(d, &blk)
              Rails.logger.debug "Building GeoData... "
              additional_info = {}
              additional_info.merge! short_description: d[:short_description] unless d[:short_description].blank?
              additional_info.merge! creator: d[:creator] unless d[:creator].blank?
          Severity: Minor
          Found in lib/mootiro_importer.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 too many return statements within this method.
          Open

              return factory.multi_point(points).as_text      if points.size > 0
          Severity: Major
          Found in lib/mootiro_importer.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                return factory.multi_polygon(polygons).as_text  if polygons.size > 0
            Severity: Major
            Found in lib/mootiro_importer.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                  return factory.multi_line_string(lines).as_text if lines.size > 0
              Severity: Major
              Found in lib/mootiro_importer.rb - About 30 mins to fix

                There are no issues that match your filters.

                Category
                Status