cityway-transdev/activeroad

View on GitHub
app/models/active_road/osm_pbf_importer.rb

Summary

Maintainability
C
7 hrs
Test Coverage

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

    def join_ways(ways)
      closed_ways = []
      endpoints_to_ways = EndpointToWayMap.new
      for way in ways
        if way.closed?
Severity: Minor
Found in app/models/active_road/osm_pbf_importer.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 initialize has 13 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def initialize(id, nodes = [], car = false, bike = false, train = false, pedestrian = false, name = "", maxspeed = 0, oneway = false, boundary = "", admin_level = "", addr_housenumber = "", options = {})
Severity: Major
Found in app/models/active_road/osm_pbf_importer.rb - About 1 hr to fix

    Method join_ways has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def join_ways(ways)
          closed_ways = []
          endpoints_to_ways = EndpointToWayMap.new
          for way in ways
            if way.closed?
    Severity: Minor
    Found in app/models/active_road/osm_pbf_importer.rb - About 1 hr to fix

      Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(id, lon, lat, addr_housenumber = "", ways = [], end_of_way = false, tags = {} )
      Severity: Major
      Found in app/models/active_road/osm_pbf_importer.rb - About 50 mins to fix

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

            def physical_road_conditionnal_costs(way)
              [].tap do |prcc|        
                prcc << [ "car", Float::MAX] if !way.car
                prcc << [ "pedestrian", Float::MAX] if !way.pedestrian
                prcc << [ "bike", Float::MAX] if !way.bike
        Severity: Minor
        Found in app/models/active_road/osm_pbf_importer.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 join_way has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def join_way(way, other)
              if way.closed?
                raise StandardError, "Trying to join a closed way to another"
              end
              if other.closed?
        Severity: Minor
        Found in app/models/active_road/osm_pbf_importer.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