cvzi/foodemoji

View on GitHub

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)

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

Error: invalid character in identifier (<unknown>, line 1)</unknown>
Open

# -*- coding: utf-8 -*-
Severity: Minor
Found in foodemoji/__init__.py by radon

We encountered an error attempting to analyze this line.

Error: invalid character in identifier (<unknown>, line 1)</unknown>
Open

#!/usr/bin/env python
Severity: Minor
Found in setup.py by radon

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`

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

    Module level import not at top of file
    Open

    import emoji
    Severity: Minor
    Found in example/example.py by pep8

    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
    Severity
    Category
    Status
    Source
    Language