DefinetlyNotAI/Test_generator

View on GitHub

Showing 15 of 23 total issues

File DataBase.py has 871 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Complexity:
    Time: BEST CASE: O(n+1) - WORST CASE: O(n^2)
        (Average time is usually 0.17ms for input size of 10,000 csv params and output of 6 params with precision of 100%)
        (Automatically 1 second is added to the time to make sure the sync is on (using `time.sleep`))
Severity: Major
Found in DataBase.py - About 2 days to fix

Function api has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    def api(self):
        """
        Handles API requests based on the provided configuration data.

        Returns:
Severity: Minor
Found in DataBase.py - About 7 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

Function __generate_data has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
Open

    def __generate_data(self, questions, exclude_list) -> tuple[
                                                              list[list[str]], int, dict[str, float], list[str]] | bool:
        """
            Generate exam data based on the provided questions and exclude list.
Severity: Minor
Found in DataBase.py - About 4 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

Function __read_csv has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def __read_csv() -> list[list[str]] | bool:
        """
            Reads a CSV file and returns a list of questions.

            The CSV file is expected to have the following structure:
Severity: Minor
Found in DataBase.py - About 2 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

Consider simplifying this complex logical expression.
Open

            if (
                    isinstance(questions_amount, int)
                    and isinstance(min_titles, int)
                    and isinstance(hard, int)
                    and isinstance(med, int)
Severity: Critical
Found in DataBase.py - About 2 hrs to fix

Function __exam_generator has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def __exam_generator(self, username) -> bool:
        """
        Generates an exam based on the provided username.

        Args:
Severity: Minor
Found in DataBase.py - About 1 hr 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 __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in DataBase.py - About 1 hr to fix

Function __create_excel has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def __create_excel() -> bool:
        """
            Creates an Excel file from a text file and saves it as an Excel file.

            Returns:
Severity: Minor
Found in DataBase.py - About 1 hr 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 deeply nested control flow statements.
Open

                            if sql.add_db(USERNAME, ["Title1", "Title2"], PASSWORD):
                                log.info("User created successfully based on the request")
                            else:
                                log.error(f"Failed to create user {USERNAME}")
                        else:
Severity: Major
Found in DataBase.py - About 45 mins to fix

Function __add_exclusion_db has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def __add_exclusion_db(self, name: str, exclusion_titles: list[str]) -> bool | None:
        """
        Adds new titles to exclude for a user in the database.

        Args:
Severity: Minor
Found in DataBase.py - About 35 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

Avoid too many return statements within this function.
Open

            return questions
Severity: Major
Found in DataBase.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return False
Severity: Major
Found in DataBase.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return False
Severity: Major
Found in DataBase.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return True
Severity: Major
Found in DataBase.py - About 30 mins to fix

Avoid too many return statements within this function.
Open

            return False
Severity: Major
Found in DataBase.py - About 30 mins to fix
Severity
Category
Status
Source
Language