cityway-transdev/activeroad

View on GitHub

Showing 31 of 33 total issues

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 split_way_with_nodes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def split_way_with_nodes(way)
          nodes_used = []
          nodes = []
          # Get nodes really used and all nodes (used and for geometry need) for a way
          way.nodes.each_with_index do |node_id, index|
    Severity: Minor
    Found in app/models/active_road/osm_pbf_importer_level_db.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 path_weights has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

      def path_weights(path)
        path_weights = 0
        
        # Add path weight
        path_weights += path_weight(path.length_in_meter) if path.respond_to?(:length_in_meter)
    Severity: Minor
    Found in lib/active_road/shortest_path/finder.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 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 ways has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

        def ways(node, context={})    
          paths =
            if GeoRuby::SimpleFeatures::Point === node
              # Search access to physical roads for departure
              ActiveRoad::AccessLink.from(node)
      Severity: Minor
      Found in lib/active_road/shortest_path/finder.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 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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

        def initialize(departure, arrival, speed = 4, constraints = [], follow_way_filter = {})    
      Severity: Minor
      Found in lib/active_road/shortest_path/finder.rb - About 35 mins to fix

        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

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

            def backup_nodes
              Rails.logger.info "Begin to backup nodes in LevelDB nodes_database in #{nodes_database_path}"
              start = Time.now
              nodes_parser = ::PbfParser.new(pbf_file)
              nodes_counter = 0
        Severity: Minor
        Found in app/models/active_road/osm_pbf_importer_level_db.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

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

            def conditionnal_costs_sum(conditionnal_costs)
              conditionnal_costs_tags = conditionnal_costs.collect(&:tags)  
              if linked?(conditionnal_costs_tags)
                if unauthorized_constraints && unauthorized_constraints_intersection_with?(conditionnal_costs_tags)
                  return Float::MAX
        Severity: Minor
        Found in app/models/active_road/request_conditionnal_cost_linker.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

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

            def self.square_sqls( size)
                result = []
                step = (1.0 / size)
                index_x = 0
                0.upto( size) do |i_x|
        Severity: Minor
        Found in lib/active_road/simulation_tool.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

        Severity
        Category
        Status
        Source
        Language