markusressel/telegram-click-aio

View on GitHub
telegram_click_aio/parser.py

Summary

Maintainability
D
2 days
Test Coverage

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
Severity: Minor
Found in telegram_click_aio/parser.py - About 1 day 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 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.
Severity: Minor
Found in telegram_click_aio/parser.py - About 4 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

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
Severity: Minor
Found in telegram_click_aio/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

Avoid deeply nested control flow statements.
Open

                    if len(current_token) > 0:
                        tokens.append(current_token)
                    current_token = ""
Severity: Major
Found in telegram_click_aio/parser.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        for name in arg.names:
                            arg_name_map.pop(name)
                    continue
    Severity: Major
    Found in telegram_click_aio/parser.py - About 45 mins to fix

      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.
      Severity: Minor
      Found in telegram_click_aio/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