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]]:
- Read upRead up
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({}), []
- Read upRead up
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()):
- Read upRead up
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():
- Read upRead up
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_(
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
)
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"),
- Read upRead up
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:
- Read upRead up
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_(
Avoid too many return
statements within this function. Open
return "CRITICAL"
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.
- Read upRead up
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"