edwardsamuel/google-maps-services-ruby

View on GitHub

Showing 7 of 9 total issues

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

    def decode(polyline)
      points = []
      index = lat = lng = 0

      while index < polyline.length
Severity: Minor
Found in lib/google_maps_service/polyline.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 directions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def directions(origin, destination,
        mode: nil, waypoints: nil, alternatives: false, avoid: nil,
        language: nil, units: nil, region: nil, departure_time: nil,
        arrival_time: nil, optimize_waypoints: false, transit_mode: nil,
        transit_routing_preference: nil)
Severity: Minor
Found in lib/google_maps_service/apis/directions.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 distance_matrix has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def distance_matrix(origins, destinations,
        mode: nil, language: nil, avoid: nil, units: nil,
        departure_time: nil, arrival_time: nil, transit_mode: nil,
        transit_routing_preference: nil)
      params = {
Severity: Minor
Found in lib/google_maps_service/apis/distance_matrix.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 decode has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def decode(polyline)
      points = []
      index = lat = lng = 0

      while index < polyline.length
Severity: Minor
Found in lib/google_maps_service/polyline.rb - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

          if arg.kind_of?(Hash)
            lat = arg[:lat] || arg[:latitude] || arg["lat"] || arg["latitude"]
            lng = arg[:lng] || arg[:longitude] || arg["lng"] || arg["longitude"]
            return lat, lng
          elsif arg.kind_of?(Array)
    Severity: Major
    Found in lib/google_maps_service/convert.rb - About 1 hr to fix

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

          def encode(points)
            last_lat = last_lng = 0
            result = ""
      
            points.each do |point|
      Severity: Minor
      Found in lib/google_maps_service/polyline.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 extract_roads_body has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def extract_roads_body(response)
              begin
                body = MultiJson.load(response.body, :symbolize_keys => true)
              rescue
                unless response.status_code == 200
      Severity: Minor
      Found in lib/google_maps_service/apis/roads.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