williamfzc/stagesepx

View on GitHub
stagesepx/toolbox.py

Summary

Maintainability
A
1 hr
Test Coverage

Consider possible security implications associated with subprocess module.
Open

import subprocess
Severity: Info
Found in stagesepx/toolbox.py by bandit

Standard pseudo-random generators are not suitable for security/cryptographic purposes.
Open

    salt = random.randint(10, 99)
Severity: Info
Found in stagesepx/toolbox.py by bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert os.path.isfile(template), f"image {template} not existed"
Severity: Info
Found in stagesepx/toolbox.py by bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert ret, f"read frame failed, frame id: {frame_id}"

Severity: Info
Found in stagesepx/toolbox.py by bandit

Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
Open

    assert os.path.isfile(img_path), f"file {img_path} is not existed"
Severity: Info
Found in stagesepx/toolbox.py by bandit

subprocess call - check for execution of untrusted input.
Open

    return subprocess.check_call(command)
Severity: Info
Found in stagesepx/toolbox.py by bandit

Function multi_compare_ssim has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def multi_compare_ssim(
    pic1_list: typing.List, pic2_list: typing.List, hooks: typing.List = None
) -> typing.List[float]:
    # avoid import loop
    from stagesepx.video import VideoFrame
Severity: Minor
Found in stagesepx/toolbox.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 compress_frame has 7 arguments (exceeds 4 allowed). Consider refactoring.
Wontfix

def compress_frame(
Severity: Major
Found in stagesepx/toolbox.py - About 50 mins to fix

    Line too long (87 > 79 characters)
    Open

            target, (0, 0), fx=compress_rate, fy=compress_rate, interpolation=interpolation
    Severity: Minor
    Found in stagesepx/toolbox.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (108 > 79 characters)
    Open

        # video_jump(cap, 2) means: moving the pointer to the start point of frame 2 => the end point of frame 1
    Severity: Minor
    Found in stagesepx/toolbox.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (101 > 79 characters)
    Open

        #     f"previous pointer: {get_current_frame_id(video_cap)}({get_current_frame_time(video_cap)})"
    Severity: Minor
    Found in stagesepx/toolbox.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (83 > 79 characters)
    Open

        - https://stackoverflow.com/questions/4993082/how-to-sharpen-an-image-in-opencv
    Severity: Minor
    Found in stagesepx/toolbox.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (85 > 79 characters)
    Open

        - https://answers.opencv.org/question/121205/how-to-refine-the-edges-of-an-image/
    Severity: Minor
    Found in stagesepx/toolbox.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    Line too long (110 > 79 characters)
    Open

        # return np.sum((pic1.astype('float') - pic2.astype('float')) ** 2) / float(pic1.shape[0] * pic2.shape[1])
    Severity: Minor
    Found in stagesepx/toolbox.py by pep8

    Limit all lines to a maximum of 79 characters.

    There are still many devices around that are limited to 80 character
    lines; plus, limiting windows to 80 characters makes it possible to
    have several windows side-by-side.  The default wrapping on such
    devices looks ugly.  Therefore, please limit all lines to a maximum
    of 79 characters. For flowing long blocks of text (docstrings or
    comments), limiting the length to 72 characters is recommended.
    
    Reports error E501.

    There are no issues that match your filters.

    Category
    Status