wikimedia/pywikibot

View on GitHub

Showing 283 of 580 total issues

File transliteration.py has 1100 lines of code (exceeds 900 allowed). Consider refactoring.
Open

"""Module to transliterate text."""
#
# (C) Pywikibot team, 2006-2024
#
# Distributed under the terms of the MIT license.
Severity: Major
Found in pywikibot/userinterfaces/transliteration.py - About 6 hrs to fix

    Function __new__ has a Cognitive Complexity of 47 (exceeds 10 allowed). Consider refactoring.
    Open

    def __new__(cls, name, bases, dct):
    """Create the new class."""
    def test_execution(script_name, args=None):
    if args is None:
    args = []
    Severity: Minor
    Found in tests/script_tests.py - About 6 hrs to fix

    File site_tests.py has 1066 lines of code (exceeds 900 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python3
    """Tests for the site module."""
    #
    # (C) Pywikibot team, 2008-2024
    #
    Severity: Major
    Found in tests/site_tests.py - About 6 hrs to fix

      Function main has a Cognitive Complexity of 43 (exceeds 10 allowed). Consider refactoring.
      Open

      def main(*args: str) -> None:
      """Process command line arguments and invoke bot.
       
      If args is an empty list, sys.argv is used.
       
       
      Severity: Minor
      Found in scripts/protect.py - About 5 hrs to fix

      File solve_disambiguation.py has 1054 lines of code (exceeds 900 allowed). Consider refactoring.
      Open

      #!/usr/bin/env python3
      """Script to help a human solve disambiguations by presenting a set of options.
       
      Specify the disambiguation page on the command line.
       
       
      Severity: Major
      Found in scripts/solve_disambiguation.py - About 5 hrs to fix

        File page_tests.py has 1051 lines of code (exceeds 900 allowed). Consider refactoring.
        Open

        #!/usr/bin/env python3
        """Tests for the page module."""
        #
        # (C) Pywikibot team, 2008-2024
        #
        Severity: Major
        Found in tests/page_tests.py - About 5 hrs to fix

          Function getCombinedGenerator has a Cognitive Complexity of 42 (exceeds 10 allowed). Consider refactoring.
          Open

          def getCombinedGenerator(self, # noqa: N802
          gen: OPT_GENERATOR_TYPE = None,
          preload: bool = False) -> OPT_GENERATOR_TYPE:
          """Return the combination of all accumulated generators.
           
           
          Severity: Minor
          Found in pywikibot/pagegenerators/_factory.py - About 5 hrs to fix

          Function get_base_dir has a Cognitive Complexity of 42 (exceeds 10 allowed). Consider refactoring.
          Open

          def get_base_dir(test_directory: str | None = None,
          config_file: str = 'user-config.py') -> str:
          r"""Return the directory in which user-specific information is stored.
           
          This is determined in the following order:
          Severity: Minor
          Found in pywikibot/config.py - About 5 hrs to fix

          Function translate has a Cognitive Complexity of 41 (exceeds 10 allowed). Consider refactoring.
          Open

          def translate(
          page=None,
          hints: list[str] | None = None,
          auto: bool = True,
          removebrackets: bool = False,
          Severity: Minor
          Found in pywikibot/titletranslate.py - About 5 hrs to fix

          Function process has a Cognitive Complexity of 40 (exceeds 10 allowed). Consider refactoring.
          Open

          def process(self, text):
          """Process the page."""
          # keys are ref groups
          # values are a dict where :
          # keys are ref content
          Severity: Minor
          Found in scripts/reflinks.py - About 5 hrs to fix

          File proofreadpage.py has 1032 lines of code (exceeds 900 allowed). Consider refactoring.
          Open

          """Objects used with ProofreadPage Extension.
           
          OCR support of page scans via:
           
          - Wikimedia OCR, see:
          Severity: Major
          Found in pywikibot/proofreadpage.py - About 5 hrs to fix

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

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

              Function parse_page_tuples has a Cognitive Complexity of 38 (exceeds 10 allowed). Consider refactoring.
              Open

              def parse_page_tuples(self, wikitext, user=None):
              """Parse page details apart from 'user:' for use."""
              whitelist = defaultdict(set)
               
              current_user = False
              Severity: Minor
              Found in scripts/patrol.py - About 4 hrs to fix

              Function preloadpages has a Cognitive Complexity of 37 (exceeds 10 allowed). Consider refactoring.
              Open

              def preloadpages(
              self,
              pagelist: Iterable[pywikibot.Page],
              *,
              groupsize: int | None = None,
              Severity: Minor
              Found in pywikibot/site/_generators.py - About 4 hrs to fix

              Function editEntity has a Cognitive Complexity of 35 (exceeds 10 allowed). Consider refactoring.
              Open

              def editEntity(
              self,
              data: ENTITY_DATA_TYPE | None = None,
              **kwargs
              ) -> None:
              Severity: Minor
              Found in pywikibot/page/_wikibase.py - About 4 hrs to fix

              Function package_versions has a Cognitive Complexity of 35 (exceeds 10 allowed). Consider refactoring.
              Open

              def package_versions(
              modules: list[str] | None = None,
              builtins: bool | None = False,
              standard_lib: bool | None = None,
              ):
              Severity: Minor
              Found in pywikibot/version.py - About 4 hrs to fix

              Function analyze_page has a Cognitive Complexity of 33 (exceeds 10 allowed). Consider refactoring.
              Open

              def analyze_page(self) -> set[tuple[str, str]]:
              """Analyze DiscussionPage."""
              max_size = self.get_attr('maxarchivesize')
              max_arch_size = str2size(max_size)
              if not max_arch_size[0]:
              Severity: Minor
              Found in scripts/archivebot.py - About 4 hrs to fix

              Function put_mex_in_talk has a Cognitive Complexity of 33 (exceeds 10 allowed). Consider refactoring.
              Open

              def put_mex_in_talk(self) -> None:
              """Function to put the warning in talk page of the uploader.
               
              When the bot find that the usertalk is empty it adds the welcome
              message first. The messages are imported from welcome.py script.
              Severity: Minor
              Found in scripts/checkimages.py - About 4 hrs to fix

              Function run has a Cognitive Complexity of 32 (exceeds 10 allowed). Consider refactoring.
              Open

              def run(self) -> None:
              """Run bot."""
              def convert_from_bytes(total_bytes):
              for unit in ['B', 'K', 'M', 'G', 'T']:
              if abs(total_bytes) < 1024:
              Severity: Minor
              Found in scripts/download_dump.py - About 3 hrs to fix

              Function readOptions has a Cognitive Complexity of 31 (exceeds 10 allowed). Consider refactoring.
              Open

              def readOptions(self, option: str) -> bool:
              """Read all commandline parameters for the global container."""
              arg, _, value = option.partition(':')
              if not arg.startswith('-'):
              return False
              Severity: Minor
              Found in scripts/interwiki.py - About 3 hrs to fix
              Severity
              Category
              Status
              Source
              Language