Showing 4 of 7 total issues
Function decorate_lines
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def decorate_lines(text):
"""Decorates text with food-specific emojis
- Line by line approch
- An emoji can only occur once per line (last occurunce)
- 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 _load
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _load():
"""Load from :ref:`foodemojis.json <foodemojis-json>` file and compile
regular expressions.
Automatically called on first use :func:`decorate`
- 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 set_position:
# remove last emoji
last = set_position.pop()
line = line[:last[0]] + line[last[1]:]
cursor -= last[1] - last[0]
Function decorate_whole
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def decorate_whole(text):
"""Decorates text with food-specific emojis
- Whole text at once approch
- Emoji can occur several times per line
- 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"