markusressel/telegram-click-aio

View on GitHub

Showing 14 of 14 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
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 command has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

def command(name: str or [str], description: str = None,
            arguments: [Argument] = None,
            hidden: bool or callable = None,
            permissions: Permission = None,
            command_target: bytes = CommandTarget.UNSPECIFIED | CommandTarget.SELF,
Severity: Minor
Found in telegram_click_aio/decorator.py - About 5 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 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 __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
Severity: Minor
Found in telegram_click_aio/argument.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 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

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,
Severity: Major
Found in telegram_click_aio/argument.py - About 1 hr to fix

    Function command has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def command(name: str or [str], description: str = None,
    Severity: Major
    Found in telegram_click_aio/decorator.py - About 50 mins to fix

      Function __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, name: str or [str], description: str, allowed_values: [any], type: type = str, converter: callable = None,
      Severity: Major
      Found in telegram_click_aio/argument.py - About 50 mins to fix

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

        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

          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

            Function parse_arg_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                def parse_arg_value(self, arg: str or None) -> any:
                    """
                    Tries to parse the given value
                    :param arg: the string value
                    :return: the parsed value
            Severity: Minor
            Found in telegram_click_aio/argument.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 wrapped
            Severity: Major
            Found in telegram_click_aio/decorator.py - About 30 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

              Severity
              Category
              Status
              Source
              Language