Nekmo/pip-rating

View on GitHub
pip_rating/sources/sourcecode_page.py

Summary

Maintainability
A
3 hrs
Test Coverage

Consider simplifying this complex logical expression.
Open

        if (
            e.response is not None
            and e.response.status_code == 403
            and e.response.reason == "rate limit exceeded"
            and not github_token
Severity: Critical
Found in pip_rating/sources/sourcecode_page.py - About 1 hr to fix

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

    def search_in_readme(content: str, package_name: str) -> Optional[bool]:
        """Search for patterns in readme. If found the pattern, check if the package name is package_name.
        If the package name found is package_name, return True, else continues searching. If after all
        patterns are searched and no package name is found, return False. If any pattern matches,
        return None.
    Severity: Minor
    Found in pip_rating/sources/sourcecode_page.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 get_github_readme has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_github_readme(owner: str, repo: str) -> str:
        """Get the readme content from GitHub."""
        headers = {}
        if github_token:
            headers["Authorization"] = f"Bearer {github_token}"
    Severity: Minor
    Found in pip_rating/sources/sourcecode_page.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

    There are no issues that match your filters.

    Category
    Status