cvzi/foodemoji

View on GitHub

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)

Severity: Minor
Found in foodemoji/__init__.py - About 2 hrs to fix

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`

Severity: Minor
Found in foodemoji/__init__.py - About 55 mins to fix

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]
Severity: Major
Found in foodemoji/__init__.py - About 45 mins to fix

    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
    
    
    Severity: Minor
    Found in foodemoji/__init__.py - About 35 mins to fix

    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

    Severity
    Category
    Status
    Source
    Language