Showing 7 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
Error: invalid character in identifier (<unknown>, line 1)</unknown> Open
# -*- coding: utf-8 -*-
- Read upRead up
- Exclude checks
We encountered an error attempting to analyze this line.
Error: invalid character in identifier (<unknown>, line 1)</unknown> Open
#!/usr/bin/env python
- Read upRead up
- Exclude checks
We encountered an error attempting to analyze this line.
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"
Further reading
Module level import not at top of file Open
import emoji
- Read upRead up
- Exclude checks
Place imports at the top of the file.
Always put imports at the top of the file, just after any module
comments and docstrings, and before module globals and constants.
Okay: import os
Okay: # this is a comment\nimport os
Okay: '''this is a module docstring'''\nimport os
Okay: r'''this is a module docstring'''\nimport os
Okay:
try:\n\timport x\nexcept ImportError:\n\tpass\nelse:\n\tpass\nimport y
Okay:
try:\n\timport x\nexcept ImportError:\n\tpass\nfinally:\n\tpass\nimport y
E402: a=1\nimport os
E402: 'One string'\n"Two string"\nimport os
E402: a=1\nfrom sys import x
Okay: if x:\n import os