pip_rating/sources/sourcecode_page.py
Consider simplifying this complex logical expression. Open
Open
if (
e.response is not None
and e.response.status_code == 403
and e.response.reason == "rate limit exceeded"
and not github_token
Function search_in_readme
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
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.
- 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 get_github_readme
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
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}"
- 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"