wikimedia/pywikibot

View on GitHub

Showing 613 of 613 total issues

Similar blocks of code found in 4 locations. Consider refactoring.
Open

class TestFullyQualifiedImplicitLinkSameFamilyParser(LinkTestWikiEn):
 
"""Link tests."""
 
def test_fully_qualified_NS0_code(self):
Severity: Major
Found in tests/link_tests.py and 3 other locations - About 1 day to fix
tests/link_tests.py on lines 290..308
tests/link_tests.py on lines 364..382
tests/link_tests.py on lines 595..613

Similar blocks of code found in 4 locations. Consider refactoring.
Open

class TestPartiallyQualifiedExplicitLinkDifferentCodeParser(LinkTestWikiEn):
 
"""Link tests."""
 
def test_partially_qualified_NS0_family(self):
Severity: Major
Found in tests/link_tests.py and 3 other locations - About 1 day to fix
tests/link_tests.py on lines 364..382
tests/link_tests.py on lines 595..613
tests/link_tests.py on lines 646..664

Similar blocks of code found in 4 locations. Consider refactoring.
Open

class TestFullyQualifiedExplicitLinkSameFamilyParser(LinkTestWikiEn):
 
"""Link tests."""
 
def test_fully_qualified_NS0_code(self):
Severity: Major
Found in tests/link_tests.py and 3 other locations - About 1 day to fix
tests/link_tests.py on lines 290..308
tests/link_tests.py on lines 595..613
tests/link_tests.py on lines 646..664

File aspects.py has 1160 lines of code (exceeds 900 allowed). Consider refactoring.
Open

"""Test aspects to allow fine grained control over what tests are executed.
 
Several parts of the test infrastructure are implemented as mixins,
such as API result caching and excessive test durations.
"""
Severity: Major
Found in tests/aspects.py - About 1 day to fix

    Function main has a Cognitive Complexity of 56 (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/upload.py - About 7 hrs to fix

    File _generators.py has 1138 lines of code (exceeds 900 allowed). Consider refactoring.
    Open

    """Page filter generators provided by the pagegenerators module."""
    #
    # (C) Pywikibot team, 2008-2024
    #
    # Distributed under the terms of the MIT license.
    Severity: Major
    Found in pywikibot/pagegenerators/_generators.py - About 7 hrs to fix

      Function main has a Cognitive Complexity of 51 (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/transwikiimport.py - About 7 hrs to fix

      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

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        def test_math_edit(self):
        """Attempt adding a math claim with valid input."""
        testsite = self.get_repo()
        item = self._clean_item(testsite, 'P717')
         
         
        Severity: Major
        Found in tests/wikibase_edit_tests.py and 2 other locations - About 6 hrs to fix
        tests/wikibase_edit_tests.py on lines 346..360
        tests/wikibase_edit_tests.py on lines 402..417

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        def test_identifier_edit(self):
        """Attempt adding an external identifier claim with valid input."""
        testsite = self.get_repo()
        item = self._clean_item(testsite, 'P718')
         
         
        Severity: Major
        Found in tests/wikibase_edit_tests.py and 2 other locations - About 6 hrs to fix
        tests/wikibase_edit_tests.py on lines 259..273
        tests/wikibase_edit_tests.py on lines 402..417

        Similar blocks of code found in 3 locations. Consider refactoring.
        Open

        def test_musical_notation_edit(self):
        """Attempt adding a musical notation claim with valid input."""
        testsite = self.get_repo()
        item = self._clean_item(testsite, 'P88936')
         
         
        Severity: Major
        Found in tests/wikibase_edit_tests.py and 2 other locations - About 6 hrs to fix
        tests/wikibase_edit_tests.py on lines 259..273
        tests/wikibase_edit_tests.py on lines 346..360

        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 1067 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 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

            File solve_disambiguation.py has 1051 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

              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 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 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
              Severity
              Category
              Status
              Source
              Language