Showing 21 of 25 total issues
File test_rating.py
has 572 lines of code (exceeds 250 allowed). Consider refactoring. Open
import datetime
import json
import time
import unittest
from unittest.mock import patch, MagicMock, Mock, PropertyMock, mock_open
File results.py
has 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
import datetime
import json
import os
from typing import Optional, TYPE_CHECKING, Union, TypedDict, List, Any
File test_results.py
has 328 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
Tests for the results module.
This tests can be improved. These tests do not verify the returned outputs.
"""
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):
- 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
File rating.py
has 281 lines of code (exceeds 250 allowed). Consider refactoring. Open
import datetime
import json
import os
import logging
from functools import cached_property
Function show_packages_results
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def show_packages_results(self, dependencies: "Dependencies"):
global_rating_score = self.get_global_rating_score(dependencies)
for package in dependencies.packages.values():
if package.name not in dependencies.req_file:
continue
- 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
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
Function action
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def action(
Function find_in_directory
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def find_in_directory(cls, directory: Union[str, Path]) -> Optional["ReqFileBase"]:
"""Find requirement file in the given directory."""
if isinstance(directory, str):
directory = Path(directory)
for requirements_file in REQUIREMENTS_FILES:
- 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 analyze_file
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def analyze_file(
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.
- 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 __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function analyze_package
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def analyze_package(
Function test_save_to_cache
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_save_to_cache(
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}"
- 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 test_save_to_cache
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def test_save_to_cache(
Function get_node_from_parent
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_node_from_parent(
self, from_package: Optional["Package"] = None
) -> Optional["Node"]:
"""Given this package and a parent package, return the node in the package that
is a descendant of the parent package
- 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
Avoid too many return
statements within this function. Open
return version
Avoid too many return
statements within this function. Open
return f"=={version}"
Avoid too many return
statements within this function. Open
return f">={version},<{version.major}.{version.minor}.{version.micro + 1}"