williamfzc/stagesepx

View on GitHub
stagesepx/api.py

Summary

Maintainability
A
3 hrs
Test Coverage

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

        assert classify_result.contain(
            from_stage
        ), f"no stage {from_stage} found in result"
Severity: Info
Found in stagesepx/api.py by bandit

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

    assert not os.path.isfile(model_path), f"file {model_path} already existed"
    # handle args
Severity: Info
Found in stagesepx/api.py by bandit

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

            assert model_path.is_file(), f"file {model_path} not existed"
Severity: Info
Found in stagesepx/api.py by bandit

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

        assert config_path.as_posix().endswith(
            ".json"
        ), "config file should be json format"
Severity: Info
Found in stagesepx/api.py by bandit

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

        assert config_path.is_file(), f"no config file found in {config_path}"

        # todo: support different types in the future
Severity: Info
Found in stagesepx/api.py by bandit

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

        assert classify_result.contain(to_stage), f"no stage {to_stage} found in result"
Severity: Info
Found in stagesepx/api.py by bandit

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

        assert not output_path.is_file(), f"file {output_path} already existed"
Severity: Info
Found in stagesepx/api.py by bandit

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

def run(config: typing.Union[dict, str]):
    """
    run with config

    :param config: config file path, or a preload dict
Severity: Minor
Found in stagesepx/api.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 keras_train has 7 arguments (exceeds 4 allowed). Consider refactoring.
Wontfix

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

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

    def analyse(
    Severity: Minor
    Found in stagesepx/api.py - About 45 mins to fix

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

      def _diff(
      Severity: Minor
      Found in stagesepx/api.py - About 35 mins to fix

        Line too long (86 > 79 characters)
        Open

            target_size: typing.Sequence[int] = [int(each) for each in target_size.split("x")]
        Severity: Minor
        Found in stagesepx/api.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 (88 > 79 characters)
        Open

                assert classify_result.contain(to_stage), f"no stage {to_stage} found in result"
        Severity: Minor
        Found in stagesepx/api.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