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`))
- Create a ticketCreate a ticket
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:
- Read upRead up
- Create a ticketCreate a ticket
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.
- Read upRead up
- Create a ticketCreate a ticket
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:
- Read upRead up
- Create a ticketCreate a ticket
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)
- Create a ticketCreate a ticket
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:
- Read upRead up
- Create a ticketCreate a ticket
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__(
- Create a ticketCreate a ticket
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:
- Read upRead up
- Create a ticketCreate a ticket
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:
- Create a ticketCreate a ticket
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:
- Read upRead up
- Create a ticketCreate a ticket
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
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return False
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return False
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return True
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return False
- Create a ticketCreate a ticket