private-dreamnet/dreampower

View on GitHub
src/transform/opencv/bodypart/extract.py

Summary

Maintainability
A
1 hr
Test Coverage

Function find_color has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def find_color(img, lower, upper):
  color_mask = cv2.inRange(img, lower, upper)
  contours, _ = cv2.findContours(color_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)

  found = False
Severity: Minor
Found in src/transform/opencv/bodypart/extract.py - 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

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

def find_min(bp_list, min_a, min_b, min_diff):
    for a, _ in enumerate(bp_list):
        for b, _ in enumerate(bp_list):
            # TODO: avoid repetition (1,0) (0,1)
            diff = abs(bp_list[a].y - bp_list[b].y)
Severity: Minor
Found in src/transform/opencv/bodypart/extract.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

Remove this commented out code.
Open

            # (x, y), (MA, ma), angle = cv2.fitEllipse(cnt)

Programmers should not comment out code as it bloats programs and reduces readability.

Unused code should be deleted and can be retrieved from source control history if required.

See

  • MISRA C:2004, 2.4 - Sections of code should not be "commented out".
  • MISRA C++:2008, 2-7-2 - Sections of code shall not be "commented out" using C-style comments.
  • MISRA C++:2008, 2-7-3 - Sections of code should not be "commented out" using C++ comments.
  • MISRA C:2012, Dir. 4.4 - Sections of code should not be "commented out"

There are no issues that match your filters.

Category
Status