wikimedia/pywikibot

View on GitHub
pywikibot/data/api/_requests.py

Summary

Maintainability
C
7 hrs
Test Coverage

File _requests.py has 1010 lines of code (exceeds 900 allowed). Consider refactoring.
Open

"""Objects representing API requests."""
#
# (C) Pywikibot team, 2007-2024
#
# Distributed under the terms of the MIT license.
Severity: Major
Found in pywikibot/data/api/_requests.py - About 4 hrs to fix

    Function __init__ has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
    Open

        def __init__(self, site=None,
                     mime: dict | None = None,
                     throttle: bool = True,
                     max_retries: int | None = None,
                     retry_wait: int | None = None,
    Severity: Minor
    Found in pywikibot/data/api/_requests.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 8 arguments (exceeds 7 allowed). Consider refactoring.
    Open

        def __init__(self, site=None,
    Severity: Major
    Found in pywikibot/data/api/_requests.py - About 35 mins to fix

      Function clean_kwargs has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

          def clean_kwargs(cls, kwargs: dict) -> dict:
              """
              Convert keyword arguments into new parameters mode.
      
              If there are no other arguments in kwargs apart from the used arguments
      Severity: Minor
      Found in pywikibot/data/api/_requests.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

      TODO found
      Open

              # TODO: T154011: 'ReadOnlyError' seems replaced by 'readonly'
      Severity: Minor
      Found in pywikibot/data/api/_requests.py by fixme

      TODO found
      Open

              # TODO: Use ParamInfo request to determine valid parameters
      Severity: Minor
      Found in pywikibot/data/api/_requests.py by fixme

      TODO found
      Open

              # TODO: what other exceptions can occur here?
      Severity: Minor
      Found in pywikibot/data/api/_requests.py by fixme

      There are no issues that match your filters.

      Category
      Status