Showing 11 of 24 total issues

Function audit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def audit(
    configuration: Configuration,
    dependencies: DependencyList,
    ignore: SkjoldIgnore,
) -> List[Dict[str, Any]]:
Severity: Minor
Found in src/skjold/tasks.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 report has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def report(
    configuration: Configuration, findings: List[Dict[str, Any]]
) -> Tuple[Set[str], List[str]]:
    """Renders (ignored) findings and list of vulnerable packages to stdout and prints a short summary to stderr."""
    vulnerable_packages, ignored_findings = set({}), []
Severity: Minor
Found in src/skjold/tasks.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 read_requirements_txt_from has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def read_requirements_txt_from(file: TextIO) -> Iterator[Dependency]:
    """Reads a requirements.txt given by path and yields 'package==version' items."""
    for line_no, line in enumerate(file.readlines()):
        # Skip empty lines or lines only containing a hash.
        if line.strip().startswith("--hash") or not len(line.strip()):
Severity: Minor
Found in src/skjold/formats.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 read_pipfile_lock_from has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def read_pipfile_lock_from(file: TextIO) -> Iterator[Dependency]:
    """Reads a Pipfile.lock given by path and yields 'package==version' items."""
    json_ = json.load(file)
    for namespace in ["develop", "default"]:
        for package_name in json_[namespace].keys():
Severity: Minor
Found in src/skjold/formats.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 audit_ has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def audit_(
Severity: Major
Found in src/skjold/cli.py - About 50 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        for advisory in advisories:
                            # Check if the advisories identifier is part of the ignore list.
                            is_ignored, entry = ignore.should_ignore(
                                advisory.identifier, advisory.package_name
                            )
    Severity: Major
    Found in src/skjold/tasks.py - About 45 mins to fix

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

          def populate_from_cache(self) -> None:
              self._advisories = defaultdict(list)
              with tarfile.TarFile.open(self.path, mode="r:gz") as archive:
                  pypi_advisories = filter(
                      lambda obj: "/vulns/" in obj.name and obj.name.endswith(".yaml"),
      Severity: Minor
      Found in src/skjold/sources/pypa.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 cli has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

      def cli(
          config: Configuration,
          configuration_file: click.Path,
          verbose: bool,
      ) -> None:
      Severity: Minor
      Found in src/skjold/cli.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 ignore_ has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def ignore_(
      Severity: Minor
      Found in src/skjold/cli.py - About 35 mins to fix

        Avoid too many return statements within this function.
        Open

                    return "CRITICAL"
        Severity: Major
        Found in src/skjold/cvss.py - About 30 mins to fix

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

              def vulnerable_version_range(self) -> List[specifiers.SpecifierSet]:
                  affected_range = self._json["affected_range"]
          
                  # Gemnasium seems to invalidate/withdraw advisories by marking them this way.
                  # See pypi/pyspark/CVE-2020-27218.yml#L11 in gemnasium-db.
          Severity: Minor
          Found in src/skjold/sources/gemnasium.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

          Severity
          Category
          Status
          Source
          Language