Showing 28 of 28 total issues
File handlers.py
has 375 lines of code (exceeds 250 allowed). Consider refactoring. Open
#!/usr/bin/env python3
import functools
import logging
import random
import re
Function from_text
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def from_text(text: str) -> "Tag":
if text == "vegetarian":
return Tag.VEGETARIAN
elif text == "vegan":
return Tag.VEGAN
- 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 __str__
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def __str__(self: "Tag") -> str:
if self == Tag.VEGETARIAN:
return "vegetarian"
elif self == Tag.VEGAN:
return "vegan"
- 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 notify_subscriber
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def notify_subscriber(context: CallbackContext):
user_id = context.job.name
if not user_db.is_subscriber(user_id):
logging.error(f"{user_id} is no subscriber, but had a subscription job")
remove_subscriber(user_id)
- 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 from_text
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def from_text(text: str) -> "Query":
def extract_date(text: str) -> Optional[date]:
matches = re.search(r"(\d{4}-\d{2}-\d{2}|today|tomorrow)", text)
if matches:
if matches.group(1) == "today":
- 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 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Avoid too many return
statements within this function. Open
return Tag.CO2_B
Avoid too many return
statements within this function. Open
return "H2O E"
Avoid too many return
statements within this function. Open
return Tag.CO2_E
Avoid too many return
statements within this function. Open
return "H2O A"
Avoid too many return
statements within this function. Open
return Tag.CO2_C
Avoid too many return
statements within this function. Open
return "CO2 A"
Avoid too many return
statements within this function. Open
return "CO2 C"
Avoid too many return
statements within this function. Open
return "H2O B"
Avoid too many return
statements within this function. Open
return Tag.CO2_A
Avoid too many return
statements within this function. Open
return "climate friendly"
Avoid too many return
statements within this function. Open
return "H2O C"
Avoid too many return
statements within this function. Open
return Tag.H2O_C
Avoid too many return
statements within this function. Open
return Tag.CLIMATE_FRIENDLY
Avoid too many return
statements within this function. Open
return "CO2 E"