leandrotoledo/python-telegram-bot

View on GitHub
telegram/_utils/files.py

Summary

Maintainability
B
4 hrs
Test Coverage

Function parse_file_input has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def parse_file_input(  # pylint: disable=too-many-return-statements
    file_input: Union[FileInput, "TelegramObject"],
    tg_type: Optional[Type["TelegramObject"]] = None,
    filename: Optional[str] = None,
    attach: bool = False,
Severity: Minor
Found in telegram/_utils/files.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 parse_file_input has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def parse_file_input(  # pylint: disable=too-many-return-statements
Severity: Minor
Found in telegram/_utils/files.py - About 45 mins to fix

    Avoid too many return statements within this function.
    Open

            return InputFile(file_input, filename=filename, attach=attach)
    Severity: Major
    Found in telegram/_utils/files.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return file_input
      Severity: Major
      Found in telegram/_utils/files.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return InputFile(cast(IO, file_input), filename=filename, attach=attach)
        Severity: Major
        Found in telegram/_utils/files.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return file_input.file_id  # type: ignore[attr-defined]
          Severity: Major
          Found in telegram/_utils/files.py - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status