project-capo/amber-python-drivers

View on GitHub
src/amberdriver/drive_support/drive_support_logic.py

Summary

Maintainability
F
4 days
Test Coverage

File drive_support_logic.py has 338 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import math
import collections
import time

import os
Severity: Minor
Found in src/amberdriver/drive_support/drive_support_logic.py - About 4 hrs to fix

    Function compute_new_radius has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def compute_new_radius(speeds, scan):
        radius = speeds.radius
        if radius is not None and abs(radius) > 0.0:
            for angle, distance in sorted(scan.points, key=lambda (a, d): a, reverse=(radius < 0.0)):
                if 100.0 < distance < 5600.0:
    Severity: Minor
    Found in src/amberdriver/drive_support/drive_support_logic.py - About 3 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

    Function change_radius has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def change_radius(speeds, radius):
        if radius is None:
            return
    
        if abs(radius) > 0.0:
    Severity: Minor
    Found in src/amberdriver/drive_support/drive_support_logic.py - 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

    Function avoid has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

    def avoid(speeds, scan):
        min_distance_angle, min_distance = get_min_distance(speeds, scan)
        center_angle = get_angle(speeds.speed_left, speeds.speed_right, ROBO_WIDTH)
        if min_distance < HARD_DISTANCE_LIMIT + 0.6 * ROBO_WIDTH:
            if min_distance_angle > 0.0:
    Severity: Minor
    Found in src/amberdriver/drive_support/drive_support_logic.py - 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

    Function compute_factor_due_to_distance has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def compute_factor_due_to_distance(scan):
        factor_cosines = 0.0
        factor_gauss = 0.0
        weights_cosines = 0.0
        weights_gauss = 0.0
    Severity: Minor
    Found in src/amberdriver/drive_support/drive_support_logic.py - 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

    Function compute_acceleration has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def compute_acceleration(list_of_speeds):
        acceleration = 0.0
        if len(list_of_speeds) > 1:
            list_of_speeds_iter = iter(list_of_speeds)
            count = 0
    Severity: Minor
    Found in src/amberdriver/drive_support/drive_support_logic.py - 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

    Function limit_speed has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def limit_speed(speeds, scan):
        min_distance_angle, min_distance = get_min_distance(speeds, scan)
        if min_distance is not None and abs(speeds.linear_speed) > 25.0:
            if min_distance < HARD_DISTANCE_LIMIT:
                if speeds.linear_speed > 0.0:
    Severity: Minor
    Found in src/amberdriver/drive_support/drive_support_logic.py - 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

    Avoid deeply nested control flow statements.
    Open

                        if _distance > distance:
                            _radius = 0.8 * radius * _distance / distance
                            if _radius < radius:
                                radius = _radius
        return radius
    Severity: Major
    Found in src/amberdriver/drive_support/drive_support_logic.py - About 45 mins to fix

      Function compute_other_speed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def compute_other_speed(self, last_speeds=None):
              self.speed_left = logic.average(self.speed_front_left, self.speed_rear_left)
              self.speed_right = logic.average(self.speed_front_right, self.speed_rear_right)
              self.speed_front = logic.average(self.speed_front_left, self.speed_front_right)
              self.speed_rear = logic.average(self.speed_rear_left, self.speed_rear_right)
      Severity: Minor
      Found in src/amberdriver/drive_support/drive_support_logic.py - 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

      Function get_min_distance has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_min_distance(speeds, scan):
          center_angle = get_angle(speeds.speed_left, speeds.speed_right, ROBO_WIDTH)
          min_distance_angle = center_angle - 0.5235987755982988  # 30st
          min_distance = None
      
      
      Severity: Minor
      Found in src/amberdriver/drive_support/drive_support_logic.py - 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

      Function __call__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def __call__(self, speeds):
              scan = self.__scan
              if scan is not None:
                  avoid(speeds, scan)
                  if speeds.radius is not None and 0.0 < abs(speeds.radius) and \
      Severity: Minor
      Found in src/amberdriver/drive_support/drive_support_logic.py - 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      if abs(speeds.speed_left) > 0.0:
                          factor_for_left = abs(speed_left / speeds.speed_left)
                          speeds.speed_front_left = logic.sign(speeds.speed_front_left) * factor_for_left * \
                                                    abs(speeds.speed_front_left)
                          speeds.speed_rear_left = logic.sign(speeds.speed_rear_left) * factor_for_left * \
      Severity: Major
      Found in src/amberdriver/drive_support/drive_support_logic.py and 1 other location - About 6 hrs to fix
      src/amberdriver/drive_support/drive_support_logic.py on lines 340..345

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 99.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      if abs(speeds.speed_right) > 0.0:
                          factor_for_right = abs(speed_right / speeds.speed_right)
                          speeds.speed_front_right = logic.sign(speeds.speed_front_right) * factor_for_right * \
                                                     abs(speeds.speed_front_right)
                          speeds.speed_rear_right = logic.sign(speeds.speed_rear_right) * factor_for_right * \
      Severity: Major
      Found in src/amberdriver/drive_support/drive_support_logic.py and 1 other location - About 6 hrs to fix
      src/amberdriver/drive_support/drive_support_logic.py on lines 331..336

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 99.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      speed_right = speeds.speed_left * (2.0 * radius - ROBO_WIDTH) / (2.0 * radius + ROBO_WIDTH)
      Severity: Major
      Found in src/amberdriver/drive_support/drive_support_logic.py and 1 other location - About 1 hr to fix
      src/amberdriver/drive_support/drive_support_logic.py on lines 330..330

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 43.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

                      speed_left = speeds.speed_right * (2.0 * radius - ROBO_WIDTH) / (2.0 * radius + ROBO_WIDTH)
      Severity: Major
      Found in src/amberdriver/drive_support/drive_support_logic.py and 1 other location - About 1 hr to fix
      src/amberdriver/drive_support/drive_support_logic.py on lines 339..339

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 43.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              self.__gravity_side = self.__gravity_alpha * self.__gravity_side + \
                                    (1 - self.__gravity_alpha) * motion.acceleration_side
      Severity: Major
      Found in src/amberdriver/drive_support/drive_support_logic.py and 1 other location - About 1 hr to fix
      src/amberdriver/drive_support/drive_support_logic.py on lines 177..178

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 39.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

              self.__gravity_forward = self.__gravity_alpha * self.__gravity_forward + \
                                       (1 - self.__gravity_alpha) * motion.acceleration_forward
      Severity: Major
      Found in src/amberdriver/drive_support/drive_support_logic.py and 1 other location - About 1 hr to fix
      src/amberdriver/drive_support/drive_support_logic.py on lines 181..182

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 39.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      There are no issues that match your filters.

      Category
      Status