release-engineering/ubi-config

View on GitHub
ubiconfig/_impl/loaders/gitlab.py

Summary

Maintainability
A
2 hrs
Test Coverage

Use of unsafe yaml load. Allows instantiation of arbitrary objects. Consider yaml.safe_load().
Open

        config_dict = yaml.load(response.content, Loader=yaml.BaseLoader)
Severity: Minor
Found in ubiconfig/_impl/loaders/gitlab.py by bandit

Function _pre_load has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def _pre_load(self):
        """Iterate all branches to get a mapping of {file_path: (branch, sha1)...}"""
        files_branch_map = {}

        LOG.debug("Loading config files from all branches")
Severity: Minor
Found in ubiconfig/_impl/loaders/gitlab.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

Function load_all has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def load_all(self):
        ubi_configs = []
        for f in self._files_branch_map:
            for branch_sha1 in self._files_branch_map[f]:
                LOG.debug("Now loading %s from branch %s", f, branch_sha1[0])
Severity: Minor
Found in ubiconfig/_impl/loaders/gitlab.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

Function load has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def load(self, file_name, version=None):
        """Load file from remote repository.
        :param file_name: filename that is on remote repository in any branch
        :param version: name of remote branch
        """
Severity: Minor
Found in ubiconfig/_impl/loaders/gitlab.py - About 35 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

There are no issues that match your filters.

Category
Status