wikimedia/pywikibot

View on GitHub
pywikibot/page/_basepage.py

Summary

Maintainability
F
1 wk
Test Coverage

File _basepage.py has 1827 lines of code (exceeds 900 allowed). Consider refactoring.
Open

"""Objects representing a base object for a MediaWiki page."""
#
# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
Severity: Major
Found in pywikibot/page/_basepage.py - About 3 days to fix

    Function _check_bot_may_edit has a Cognitive Complexity of 63 (exceeds 10 allowed). Consider refactoring.
    Open

        def _check_bot_may_edit(self, module: str | None = None) -> bool:
            """A botMayEdit helper method.
    
            :param module: The module name to be restricted. Defaults to
                :func:`pywikibot.calledModuleName`.
    Severity: Minor
    Found in pywikibot/page/_basepage.py - About 1 day 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 title has a Cognitive Complexity of 30 (exceeds 10 allowed). Consider refactoring.
    Open

        def title(
            self,
            *,
            underscore: bool = False,
            with_ns: bool = True,
    Severity: Minor
    Found in pywikibot/page/_basepage.py - About 3 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 change_category has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
    Open

        def change_category(self, old_cat, new_cat,
                            summary: str | None = None,
                            sort_key=None,
                            in_place: bool = True,
                            include: list[str] | None = None,
    Severity: Minor
    Found in pywikibot/page/_basepage.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 isCategoryRedirect has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
    Open

        def isCategoryRedirect(self) -> bool:
            """Return True if this is a category redirect page, False otherwise."""
            if not self.is_categorypage():
                return False
    
    
    Severity: Minor
    Found in pywikibot/page/_basepage.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 delete has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
    Open

        def delete(
            self,
            reason: str | None = None,
            prompt: bool = True,
            mark: bool = False,
    Severity: Minor
    Found in pywikibot/page/_basepage.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 extract has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
    Open

        def extract(self, variant: str = 'plain', *,
                    lines: int | None = None,
                    chars: int | None = None,
                    sentences: int | None = None,
                    intro: bool = True) -> str:
    Severity: Minor
    Found in pywikibot/page/_basepage.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 revisions has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
    Open

        def revisions(self,
                      reverse: bool = False,
                      total: int | None = None,
                      content: bool = False,
                      starttime=None, endtime=None):
    Severity: Minor
    Found in pywikibot/page/_basepage.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 title has 12 arguments (exceeds 7 allowed). Consider refactoring.
    Open

        def title(
    Severity: Major
    Found in pywikibot/page/_basepage.py - About 1 hr to fix

      Function put has 11 arguments (exceeds 7 allowed). Consider refactoring.
      Open

          def put(self, newtext: str,
      Severity: Major
      Found in pywikibot/page/_basepage.py - About 1 hr to fix

        Consider simplifying this complex logical expression.
        Open

                    if force_interwiki \
                       or (allow_interwiki
                           and (self.site.family.name != target_family
                                or self.site.code != target_code)):
                        if self.site.family.name not in (
        Severity: Major
        Found in pywikibot/page/_basepage.py - About 1 hr to fix

          Function save has 11 arguments (exceeds 7 allowed). Consider refactoring.
          Open

              def save(self,
          Severity: Major
          Found in pywikibot/page/_basepage.py - About 1 hr to fix

            Function isDisambig has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
            Open

                def isDisambig(self) -> bool:
                    """
                    Return True if this is a disambiguation page, False otherwise.
            
                    By default, it uses the Disambiguator extension's result. The
            Severity: Minor
            Found in pywikibot/page/_basepage.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

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

                def getReferences(self,
            Severity: Major
            Found in pywikibot/page/_basepage.py - About 35 mins to fix

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

                  def _save(self, summary=None, watch=None, minor: bool = True, botflag=None,
              Severity: Major
              Found in pywikibot/page/_basepage.py - About 35 mins to fix

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

                    def change_category(self, old_cat, new_cat,
                Severity: Major
                Found in pywikibot/page/_basepage.py - About 35 mins to fix

                  Avoid too many return statements within this function.
                  Open

                                      return False
                  Severity: Major
                  Found in pywikibot/page/_basepage.py - About 30 mins to fix

                    Avoid too many return statements within this function.
                    Open

                            return True
                    Severity: Major
                    Found in pywikibot/page/_basepage.py - About 30 mins to fix

                      Avoid too many return statements within this function.
                      Open

                                              return False
                      Severity: Major
                      Found in pywikibot/page/_basepage.py - About 30 mins to fix

                        Avoid too many return statements within this function.
                        Open

                                                return False
                        Severity: Major
                        Found in pywikibot/page/_basepage.py - About 30 mins to fix

                          Avoid too many return statements within this function.
                          Open

                                                  return False
                          Severity: Major
                          Found in pywikibot/page/_basepage.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                                    return False
                            Severity: Major
                            Found in pywikibot/page/_basepage.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                                  return False
                              Severity: Major
                              Found in pywikibot/page/_basepage.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                        return False
                                Severity: Major
                                Found in pywikibot/page/_basepage.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                      return False
                                  Severity: Major
                                  Found in pywikibot/page/_basepage.py - About 30 mins to fix

                                    FIXME found
                                    Open

                                            # FIXME: We might want to fill _langlinks when the Site
                                    Severity: Minor
                                    Found in pywikibot/page/_basepage.py by fixme

                                    TODO found
                                    Open

                                                # TODO: what other exceptions might be returned?
                                    Severity: Minor
                                    Found in pywikibot/page/_basepage.py by fixme

                                    FIXME found
                                    Open

                                            # FIXME: bug T75561: with_sort_key is ignored by Site.pagecategories
                                    Severity: Minor
                                    Found in pywikibot/page/_basepage.py by fixme

                                    TODO found
                                    Open

                                            # TODO: Only request uncached revisions
                                    Severity: Minor
                                    Found in pywikibot/page/_basepage.py by fixme

                                    There are no issues that match your filters.

                                    Category
                                    Status