django/utils/html.py
File html.py
has 355 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
"""HTML utilities suitable for global use."""
import html
import json
import re
Function handle_word
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
Open
def handle_word(
self,
word,
*,
safe_input,
- 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 trim_punctuation
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
Open
def trim_punctuation(self, word):
"""
Trim trailing and wrapping punctuation from `word`. Return the items of
the new state.
"""
- 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 handle_word
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def handle_word(
Avoid too many return
statements within this function. Open
Open
return word
Avoid too many return
statements within this function. Open
Open
return escape(word)
Avoid too many return
statements within this function. Open
Open
return mark_safe(word)