gmantelet/python-lyth

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

Summary

Maintainability
B
5 hrs
Test Coverage

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

    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 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 addition has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Wontfix

        def addition(self) -> Node:
            """
            Looking for a token that could lead to an addition or a substraction.
    
            It returns the result of a numeral, or a chain of additions. If an
    Severity: Minor
    Found in src/lyth/compiler/parser.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 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

    There are no issues that match your filters.

    Category
    Status