gmantelet/python-lyth

View on GitHub
src/lyth/compiler/symbol.py

Summary

Maintainability
B
6 hrs
Test Coverage

File symbol.py has 312 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
This module defines the symbol table.
"""
from __future__ import annotations

Severity: Minor
Found in src/lyth/compiler/symbol.py - About 3 hrs to fix

    Function __getitem__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __getitem__(self, info: Union[str, Tuple[str, str]]) -> Union[Name, List[Name]]:
            """
            Retrieves an instance of Name based on its information.
    
            If the information is only a name, then it returns all the names in the
    Severity: Minor
    Found in src/lyth/compiler/symbol.py - About 1 hr 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 __add__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def __add__(self, other: Name) -> Name:
            """
            Insert a name to this instance.
            """
            if self < other:
    Severity: Minor
    Found in src/lyth/compiler/symbol.py - About 45 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

    Function __delitem__ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def __delitem__(self, info: Tuple[str, str]) -> None:
            """
            Delete a node from this symbol table. It can be the root node itself.
    
            When it deletes a node, delitem also deletes the children nodes of this
    Severity: Minor
    Found in src/lyth/compiler/symbol.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

    Avoid too many return statements within this function.
    Open

                return [child for child in self() if child.name == info]
    Severity: Major
    Found in src/lyth/compiler/symbol.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return self.right[info]
      Severity: Major
      Found in src/lyth/compiler/symbol.py - About 30 mins to fix

        There are no issues that match your filters.

        Category
        Status