leandrotoledo/python-telegram-bot

View on GitHub
telegram/request/_requestparameter.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function _value_and_input_files_from_input has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def _value_and_input_files_from_input(  # pylint: disable=too-many-return-statements
        value: object,
    ) -> Tuple[object, List[InputFile]]:
        """Converts `value` into something that we can json-dump. Returns two values:
        1. the JSON-dumpable value. Maybe be `None` in case the value is an InputFile which must
Severity: Minor
Found in telegram/request/_requestparameter.py - About 2 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 from_input has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def from_input(cls, key: str, value: object) -> "RequestParameter":
        """Builds an instance of this class for a given key-value pair that represents the raw
        input as passed along from a method of :class:`telegram.Bot`.
        """
        if not isinstance(value, (str, bytes)) and isinstance(value, Sequence):
Severity: Minor
Found in telegram/request/_requestparameter.py - About 55 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 value.to_dict(), []
Severity: Major
Found in telegram/request/_requestparameter.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return data, [value.sticker]
    Severity: Major
    Found in telegram/request/_requestparameter.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return value, []
      Severity: Major
      Found in telegram/request/_requestparameter.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return data, [value.media, thumbnail]
        Severity: Major
        Found in telegram/request/_requestparameter.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                      return data, [value.media]
          Severity: Major
          Found in telegram/request/_requestparameter.py - About 30 mins to fix

            There are no issues that match your filters.

            Category
            Status