wikimedia/pywikibot

View on GitHub
pywikibot/userinterfaces/terminal_interface_base.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function _print has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
Open

    def _print(self, text, target_stream) -> None:
        """Write the text to the target stream handling the colors."""
        colorized = (config.colorized_output
                     and self.support_color(target_stream))
        colored_line = False
Severity: Minor
Found in pywikibot/userinterfaces/terminal_interface_base.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 stream_output has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
Open

    def stream_output(self, text, targetStream=None) -> None:
        """Output text to a stream.

        If a character can't be displayed in the encoding used by the user's
        terminal, it will be replaced with a question mark or by a
Severity: Minor
Found in pywikibot/userinterfaces/terminal_interface_base.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 option.handled(answer):
                            answer = option.result(answer)
                            output_option(option, before_question=False)
                            handled = option.stop
                            break
Severity: Major
Found in pywikibot/userinterfaces/terminal_interface_base.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if force:
                                raise ValueError(
                                    f'{default!r} is not a valid Option for '
                                    f'{removeprefix(output, question).lstrip()}')
    
    
    Severity: Major
    Found in pywikibot/userinterfaces/terminal_interface_base.py - About 45 mins to fix

      Function input has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
      Open

          def input(self, question: str,
                    password: bool = False,
                    default: str | None = '',
                    force: bool = False) -> str:
              """
      Severity: Minor
      Found in pywikibot/userinterfaces/terminal_interface_base.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

      TODO found
      Open

                  # TODO: Test for uniquity

      TODO found
      Open

                  # TODO: make sure this is logged as well

      There are no issues that match your filters.

      Category
      Status