project-capo/amber-python-drivers

View on GitHub
src/amberdriver/drive_to_point/drive_to_point.py

Summary

Maintainability
D
3 days
Test Coverage

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

    def __find_temporary_target(scan, drive_distance, drive_angle, location, current_target):
        best_current_temporary_distance = None
        best_temporary_x, best_temporary_y = None, None
        for angle, distance in sorted(scan.points, key=lambda (a, _): a):
            if distance > drive_distance:
Severity: Minor
Found in src/amberdriver/drive_to_point/drive_to_point.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

DriveToPoint has 22 functions (exceeds 20 allowed). Consider refactoring.
Open

class DriveToPoint(object):
    TIMESTAMP_FIELD = 4

    def __init__(self, driver_proxy, location_proxy, hokuyo_proxy):
        self.__driver_proxy = driver_proxy
Severity: Minor
Found in src/amberdriver/drive_to_point/drive_to_point.py - About 2 hrs to fix

    File drive_to_point.py has 262 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import logging
    import logging.config
    import threading
    import time
    import math
    Severity: Minor
    Found in src/amberdriver/drive_to_point/drive_to_point.py - About 2 hrs to fix

      Function __drive_to has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def __drive_to(self, target, next_targets_timestamp):
              self.__logger.info('Drive to %s', str(target))
      
              location = self.__locator.get_absolute_location()
      
      
      Severity: Minor
      Found in src/amberdriver/drive_to_point/drive_to_point.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 __check_temporary_target has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def __check_temporary_target(scan, point):
              for alpha in logic.drange(0, 1.5707963267948966, 0.17453292519943295):
                  x, y = logic.convert_polar_to_grid(ROBO_WIDTH * 0.35, alpha)
                  _a, _d = logic.convert_grid_to_polar(x + point[0], y + point[1])
                  s_d = drive_support_logic.get_distance(scan, _a)
      Severity: Minor
      Found in src/amberdriver/drive_to_point/drive_to_point.py - 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 deeply nested control flow statements.
      Open

                              if (best_current_temporary_distance is None or
                                          current_temporary_distance < best_current_temporary_distance) and \
                                      condition:
                                  best_temporary_x, best_temporary_y = temporary_x, temporary_y
                                  best_current_temporary_distance = current_temporary_distance
      Severity: Major
      Found in src/amberdriver/drive_to_point/drive_to_point.py - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

                return True
        Severity: Major
        Found in src/amberdriver/drive_to_point/drive_to_point.py - About 30 mins to fix

          Function driving_loop has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              def driving_loop(self):
                  driving = False
                  while self.__is_active:
                      target = self.__get_next_target()
                      while self.__is_active and target is not None:
          Severity: Minor
          Found in src/amberdriver/drive_to_point/drive_to_point.py - 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

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

              def get_visited_target_and_location(self):
                  self.__targets_lock.acquire()
                  try:
                      _visited_target = self.__visited_targets[-1] if len(self.__visited_targets) > 0 else (0, 0, 0)
                      return _visited_target, self.__current_location
          Severity: Major
          Found in src/amberdriver/drive_to_point/drive_to_point.py and 1 other location - About 3 hrs to fix
          src/amberdriver/drive_to_point/drive_to_point.py on lines 90..96

          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 70.

          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

              def get_next_target_and_location(self):
                  self.__targets_lock.acquire()
                  try:
                      _next_target = self.__next_targets[0] if len(self.__next_targets) > 0 else (0, 0, 0)
                      return _next_target, self.__current_location
          Severity: Major
          Found in src/amberdriver/drive_to_point/drive_to_point.py and 1 other location - About 3 hrs to fix
          src/amberdriver/drive_to_point/drive_to_point.py on lines 105..111

          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 70.

          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

              def get_visited_targets_and_location(self):
                  self.__targets_lock.acquire()
                  try:
                      return self.__visited_targets[:], self.__current_location
                  finally:
          Severity: Major
          Found in src/amberdriver/drive_to_point/drive_to_point.py and 1 other location - About 1 hr to fix
          src/amberdriver/drive_to_point/drive_to_point.py on lines 83..88

          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 41.

          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

              def get_next_targets_and_location(self):
                  self.__targets_lock.acquire()
                  try:
                      return self.__next_targets[:], self.__current_location
                  finally:
          Severity: Major
          Found in src/amberdriver/drive_to_point/drive_to_point.py and 1 other location - About 1 hr to fix
          src/amberdriver/drive_to_point/drive_to_point.py on lines 98..103

          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 41.

          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

                                              abs(temporary_y - location.y) > abs(current_target[1] - location.y)
          Severity: Minor
          Found in src/amberdriver/drive_to_point/drive_to_point.py and 1 other location - About 55 mins to fix
          src/amberdriver/drive_to_point/drive_to_point.py on lines 233..233

          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 37.

          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

                                  condition = abs(temporary_x - location.x) > abs(current_target[0] - location.x) or \
          Severity: Minor
          Found in src/amberdriver/drive_to_point/drive_to_point.py and 1 other location - About 55 mins to fix
          src/amberdriver/drive_to_point/drive_to_point.py on lines 234..234

          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 37.

          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 3 locations. Consider refactoring.
          Open

          class ScanHandler(Listener):
              def __init__(self, driver):
                  self.__drive_to_point = driver
          
              def handle(self, response):
          Severity: Major
          Found in src/amberdriver/drive_to_point/drive_to_point.py and 2 other locations - About 50 mins to fix
          src/amberdriver/drive_support/drive_support.py on lines 25..30
          src/amberdriver/drive_support/drive_support.py on lines 33..38

          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 36.

          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