Showing 24 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
- Read upRead up
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
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
- Read upRead up
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
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
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
- Read upRead up
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
- Read upRead up
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.
- Read upRead up
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:
- Read upRead up
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
- Read upRead up
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]
Avoid too many return
statements within this function. Open
return [child for child in self() if child.name == info]
Avoid too many return
statements within this function. Open
return self
Avoid too many return
statements within this function. Open
return self
Avoid too many return
statements within this function. Open
return self
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
- Read upRead up
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
- Read upRead up
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
The input method in Python 2 will read from standard input, evaluate and run the resulting string as python source code. This is similar, though in many ways worse, then using eval. On Python 2, use raw_input instead, input is safe in Python 3. Open
source = input('>>> ')
- Exclude checks
TODO found Open
# TODO: This is a bypass. I need a blockchain now.
- Exclude checks
Refactor this function to reduce its Cognitive Complexity from 22 to the 15 allowed. Open
def main(argv=sys.argv):
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.