Showing 8 of 8 total issues
Function cluster
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def cluster(cohort_submissions: dict) -> list:
"""
Splits given dict into clusters of 4 based on their ranked complexity
The 'remainder problem' of needing to have 4 submissions per cluster,
- 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 image_confidence
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def image_confidence(image_path):
"""
Detects text in images and calculates the confidence level for each
character. Returns a True boolean if the overall confidence for the
page is less than 0.85. Otherwise, returns False
- 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 metrics
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def metrics(document: str):
"""
Cleans and generates metrics for a single story transcription.
Called within squad_score async function, so only need be run separately
- 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 deeply nested control flow statements. Open
if self.text_moderator.check_word(str(word).lower()):
flagged = True
for symbol in word.symbols:
Avoid deeply nested control flow statements. Open
for symbol in word.symbols:
symbol_confidences.append(symbol.confidence)
# Calculate the overall confidence for the page
page_confidence = sum(symbol_confidences) / len(symbol_confidences)
Avoid deeply nested control flow statements. Open
for symbol in word.symbols:
symbol_confidences.append(symbol.confidence)
# If there is no text on the page
if len(symbol_confidences) == 0:
Avoid too many return
statements within this function. Open
return JSONResponse(
Avoid too many return
statements within this function. Open
return custom_route_handler