gmantelet/python-lyth

View on GitHub

Showing 17 of 34 total issues

Function next has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

    def next(self) -> Token:
        """
        Get the next token in source being scanned.

        This method assumes spaces as delimiters. Spaces in python comprise
Severity: Minor
Found in src/lyth/compiler/lexer.py - About 7 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

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 __add__ has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def __add__(self, lexeme: str) -> Token:
            """
            Add a scanned character to an existing token.
    
            This method validates that the character appended to the existing token
    Severity: Minor
    Found in src/lyth/compiler/token.py - About 3 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

    File parser.py has 291 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    This module contains the parser.
    
    The Parser uses the Lexer to retrieve a series of tokens, and based on these
    tokens, it performs syntax analysis. It should give an Abstract Syntax Tree in
    Severity: Minor
    Found in src/lyth/compiler/parser.py - About 3 hrs to fix

      Consider simplifying this complex logical expression.
      Open

              if symbol is not None and self.symbol in Literal:
                  raise LythSyntaxError(self.info, msg=LythError.MISSING_SPACE_BEFORE_OPERATOR)
      
              elif lexeme.isdigit() and self.symbol in Literal:
                  self.lexeme += lexeme
      Severity: Critical
      Found in src/lyth/compiler/token.py - About 2 hrs to fix

        Function block has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
        Open

            def block(self) -> List[Node]:
                """
                Processing a list of indented statements following a colon.
        
                Original token is provided as parameter to help this method wraps the
        Severity: Minor
        Found in src/lyth/compiler/parser.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 __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 assign has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
        Open

            def assign(self) -> Node:
                """
                Based on a left-member expression, check that we are dealing with an
                assign, be mutable or immutable.
        
        
        Severity: Minor
        Found in src/lyth/compiler/parser.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 self.right[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 [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
            Severity: Major
            Found in src/lyth/compiler/token.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                          return self
              Severity: Major
              Found in src/lyth/compiler/token.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return self
                Severity: Major
                Found in src/lyth/compiler/token.py - About 30 mins to fix

                  Function __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def __init__(self, lexeme: str, scan: Scanner, force_literal=False) -> None:
                          """
                          Instantiate a new Token.
                  
                          Instantiates a new Token object if the provided symbol is a _Lexeme. If
                  Severity: Minor
                  Found in src/lyth/compiler/token.py - About 25 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 let has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def let(self) -> Tuple[Node, Optional[Token]]:
                          """
                          Is there any let keyword that wants to come out?
                  
                          Let keyword declares a node to be declared publicly in our tree of
                  Severity: Minor
                  Found in src/lyth/compiler/parser.py - About 25 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