Showing 17 of 17 total issues
Function parse_command_args
has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring. Open
def parse_command_args(arguments: str or None, expected_args: List[Argument]) -> dict:
"""
Parses the given argument text
:param arguments: the argument text
:param expected_args: a list of expected arguments
- 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 split_into_tokens
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def split_into_tokens(text: str) -> List[str]:
"""
This is a simple shell-style tokenizer for command arguments.
The goal was to emulate posix behaviour, while maintaining quotation characters,
to be able to differentiate quoted and non-quoted tokens even after tokenization.
- 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 _create_callback_wrapper
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def _create_callback_wrapper(func: callable, help_message: str,
arguments: [Argument],
permissions: Permission,
command_target: bytes,
error_handlers: List[ErrorHandler]) -> callable:
- 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 __init__
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, name: str or [str], description: str, example: str, type: type = str, converter: callable = None,
flag: bool = False, optional: bool = False, default: any = None, validator: callable = None):
"""
Creates a command argument object
:param name: the name (or names) of the argument
- 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 starts_with_naming_prefix
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def starts_with_naming_prefix(arg: str, abbreviated: bool or None = None) -> bool:
"""
Checks if the given string starts
:param arg: the arg to check
:param abbreviated: whether to look for a prefix used for abbreviated argument keys
- 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 __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, name: str or [str], description: str, example: str, type: type = str, converter: callable = None,
Function command
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def command(name: str or [str], description: str = None,
Function __init__
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, name: str, description: str, allowed_values: [any], type: type = str, converter: callable = None,
Function find_duplicates
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def find_duplicates(l: list) -> []:
"""
Finds duplicate entries in the given list
:param l: the list to check
:return: map of (value -> list of indexes)
- 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 _create_callback_wrapper
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _create_callback_wrapper(func: callable, help_message: str,
Avoid deeply nested control flow statements. Open
if len(current_token) > 0:
tokens.append(current_token)
current_token = ""
Avoid deeply nested control flow statements. Open
for name in arg.names:
arg_name_map.pop(name)
continue
Function parse_arg_value
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def parse_arg_value(self, arg: str) -> any:
"""
Tries to parse the given value
:param arg: the string value
:return: the parsed value
- 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 wrapper
Function is_quoted
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def is_quoted(text: str or any) -> bool:
"""
Checks if the given text is quoted.
Note: This method expects a stripped text!
When passing something other than a str, the result will always be False.
- 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 generate_synopsis
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def generate_synopsis(names: [str], args: List[Argument]) -> str:
"""
Generates the synopsis for a command
:param names: command names
:param args: arguments
- 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 check_optional_argument_after_other
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def check_optional_argument_after_other(command_name: str, arguments: List[Argument]):
"""
Checks the order of arguments to make sure no required argument is defined after an optional one
:param command_name: command name the arguments belong to
:param arguments: arguments to check
- 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"