Nekmo/pip-rating

View on GitHub
pip_rating/req_files/pyproject.py

Summary

Maintainability
B
4 hrs
Test Coverage

Function poetry_version has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def poetry_version(version: Union[str, dict, None]) -> str:
    """Convert Poetry version to PEP440 version."""
    if version is None:
        return ""
    if isinstance(version, dict):
Severity: Minor
Found in pip_rating/req_files/pyproject.py - About 3 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

Avoid too many return statements within this function.
Open

        return version
Severity: Major
Found in pip_rating/req_files/pyproject.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return f"=={version}"
    Severity: Major
    Found in pip_rating/req_files/pyproject.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return f">={version},<{version.major}.{version.minor}.{version.micro + 1}"
      Severity: Major
      Found in pip_rating/req_files/pyproject.py - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status