wikimedia/pywikibot

View on GitHub
pywikibot/_wbtypes.py

Summary

Maintainability
C
1 day
Test Coverage

File _wbtypes.py has 947 lines of code (exceeds 900 allowed). Consider refactoring.
Open

"""Wikibase data type classes."""
#
# (C) Pywikibot team, 2013-2024
#
# Distributed under the terms of the MIT license.
Severity: Major
Found in pywikibot/_wbtypes.py - About 3 hrs to fix

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

        def __init__(self,
                     year: int | None = None,
                     month: int | None = None,
                     day: int | None = None,
                     hour: int | None = None,
    Severity: Minor
    Found in pywikibot/_wbtypes.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 __init__ has 12 arguments (exceeds 7 allowed). Consider refactoring.
    Open

        def __init__(self,
    Severity: Major
    Found in pywikibot/_wbtypes.py - About 1 hr to fix

      Function normalize has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def normalize(self) -> WbTime:
              """Normalizes the WbTime object to account for precision.
      
              Normalization is needed because WbTime objects can have hidden
              values that affect naive comparisons, such as an object set to
      Severity: Minor
      Found in pywikibot/_wbtypes.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 11 arguments (exceeds 7 allowed). Consider refactoring.
      Open

          def __init__(self, lat: float, lon: float, alt: float | None = None,
      Severity: Major
      Found in pywikibot/_wbtypes.py - About 1 hr to fix

        Function fromTimestamp has 8 arguments (exceeds 7 allowed). Consider refactoring.
        Open

            def fromTimestamp(cls,
        Severity: Major
        Found in pywikibot/_wbtypes.py - About 35 mins to fix

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

              def _getSecondsAdjusted(self) -> int:
                  """Return an internal representation of the time object as seconds.
          
                  The value adjusts itself for timezones. It is not compatible
                  with before/after.
          Severity: Minor
          Found in pywikibot/_wbtypes.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

                      radius = 6378137  # TODO: Support other globes
          Severity: Minor
          Found in pywikibot/_wbtypes.py by fixme

          TODO found
          Open

                  # TODO: This method signature does not match our parent class (which
          Severity: Minor
          Found in pywikibot/_wbtypes.py by fixme

          FIXME found
          Open

                  FIXME: Should this be in the DataSite object?
          Severity: Minor
          Found in pywikibot/_wbtypes.py by fixme

          There are no issues that match your filters.

          Category
          Status