cgddrd/CS39440-major-project

View on GitHub
src/feature_tracking_motion_displacement/main.py

Summary

Maintainability
F
1 mo
Test Coverage

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

def calc_lk_patches_flow(image1, image2, feature_params, patch_size, max_val_threshold, use_subpix=False):

    count = 0
    raw_results = {}
    half_patch_size = round(patch_size / 2)
Severity: Minor
Found in src/feature_tracking_motion_displacement/main.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 run_sim has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

def run_sim(folder_path, images, feature_params, lk_params, subpix_params):

    count = 0

    # Create some random colors
Severity: Minor
Found in src/feature_tracking_motion_displacement/main.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 draw_arrow has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

def draw_arrow(image, p, q, color, arrow_magnitude=9, thickness=1, line_type=8, shift=0):
Severity: Major
Found in src/feature_tracking_motion_displacement/main.py - About 1 hr to fix

    Function calc_lk_patches_flow has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def calc_lk_patches_flow(image1, image2, feature_params, patch_size, max_val_threshold, use_subpix=False):
    Severity: Minor
    Found in src/feature_tracking_motion_displacement/main.py - About 45 mins to fix

      Function calc_lk_tracking_flow has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def calc_lk_tracking_flow(image1, image2, feature_params, lk_params, use_subpix=False):
      Severity: Minor
      Found in src/feature_tracking_motion_displacement/main.py - About 35 mins to fix

        Function run_sim has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def run_sim(folder_path, images, feature_params, lk_params, subpix_params):
        Severity: Minor
        Found in src/feature_tracking_motion_displacement/main.py - About 35 mins to fix

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

          def calc_lk_patches_flow(image1, image2, feature_params, patch_size, max_val_threshold, use_subpix=False):
          
              count = 0
              raw_results = {}
              half_patch_size = round(patch_size / 2)
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 1 wk to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 119..215

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

          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

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

                  if count == 0:
          
                      mask = np.zeros_like(image_loaded)
          
                      old_gray = cv2.cvtColor(image_loaded[image_height_quarter: image_height, 0:image_width], cv2.COLOR_BGR2GRAY)
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 4 days to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 311..368

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

          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

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

          def calc_lk_tracking_flow(image1, image2, feature_params, lk_params, use_subpix=False):
          
              image1_gray = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
              image2_gray = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY)
          
          
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 4 days to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 89..117

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

          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

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

          def draw_arrow(image, p, q, color, arrow_magnitude=9, thickness=1, line_type=8, shift=0):
          
              # draw arrow tail
              cv2.line(image, p, q, color, thickness, line_type, shift)
          
          
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 2 days to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 37..57

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

          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

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

          def cut_array2d(array, shape):
              arr_shape = np.shape(array)
              xcut = np.linspace(0,arr_shape[0],shape[0]+1).astype(np.int)
              ycut = np.linspace(0,arr_shape[1],shape[1]+1).astype(np.int)
              blocks = []
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 2 days to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 218..230

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

          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

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

          def draw_flow(img, flow, step=16):
              h, w = img.shape[:2]
              y, x = np.mgrid[step/2:h:step, step/2:w:step].reshape(2,-1)
          
              y = y.astype(int)
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 2 days to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 69..87

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

          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

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

          def filter_angle(old_points, new_points, vectors):
          
              bool_result = np.ones(len(old_points), dtype=bool)
          
              for i, (new, old) in enumerate(zip(new_points, old_points)):
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 1 day to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 271..290

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

          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

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

          def filter_outliers_ab_dist_median_indices(data, ab_dist_median_factor=2.):
          
              # Ensure we are dealing with a numpy array before operating.
              data = np.array(data)
          
          
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 5 hrs to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 22..34

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

          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

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

          def filter_direction(old_points, new_points):
          
              bool_result = np.ones(len(old_points), dtype=bool)
          
              for i, (new, old) in enumerate(zip(new_points, old_points)):
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 5 hrs to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 257..268

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

          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

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

          def angle_between(v1, v2):
              """ Returns the angle in radians between vectors 'v1' and 'v2'::
          
                      >>> angle_between((1, 0, 0), (0, 1, 0))
                      1.5707963267948966
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 4 hrs to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 236..254

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

          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

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

          def calc_farneback_flow(image1, image2):
          
              image1_gray = cv2.cvtColor(image1, cv2.COLOR_BGR2GRAY)
              image2_gray = cv2.cvtColor(image2, cv2.COLOR_BGR2GRAY)
          
          
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 3 hrs to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 59..66

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

          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

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

          def calc_moving_average_array(values, window, mode='valid'):
          
              weights = np.repeat(1.0, window)/window
          
              # Including 'valid' MODE will REQUIRE there to be enough data points.
          Severity: Major
          Found in src/feature_tracking_motion_displacement/main.py and 1 other location - About 1 hr to fix
          final/technical_work/additional_work/python/feature_tracking_motion_displacement/test_features.py on lines 14..19

          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