wikimedia/pywikibot

View on GitHub

Showing 283 of 580 total issues

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

def handle_args(args: Iterable[str] | None = None,
do_help: bool = True) -> list[str]:
"""Handle global command line arguments and return the rest as a list.
 
Takes the command line arguments as strings, processes all
Severity: Minor
Found in pywikibot/bot.py - About 3 hrs to fix

Function replace_links has a Cognitive Complexity of 30 (exceeds 10 allowed). Consider refactoring.
Open

def replace_links(self, text, linked_page, target_page):
"""Replace all source links by target."""
mysite = pywikibot.Site()
linktrail = mysite.linktrail()
 
 
Severity: Minor
Found in scripts/fixing_redirects.py - About 3 hrs to fix

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

Function deprecated_args has a Cognitive Complexity of 30 (exceeds 10 allowed). Consider refactoring.
Open

def deprecated_args(**arg_pairs: str | None):
"""Decorator to declare multiple args deprecated.
 
**Usage:**
 
 
Severity: Minor
Found in pywikibot/tools/_deprecate.py - About 3 hrs to fix

Function remove_templates has a Cognitive Complexity of 29 (exceeds 10 allowed). Consider refactoring.
Open

def remove_templates(self):
"""Understand if the page is blocked has the right template."""
 
def understand_block():
"""Understand if the page is blocked has the right template."""
Severity: Minor
Found in scripts/blockpageschecker.py - About 3 hrs to fix

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

Function batched has a Cognitive Complexity of 28 (exceeds 10 allowed). Consider refactoring.
Open

def batched(iterable, n: int, *,
strict: bool = False) -> Generator[tuple]:
"""Batch data from the *iterable* into tuples of length *n*.
 
.. note:: The last batch may be shorter than *n* if *strict* is
Severity: Minor
Found in pywikibot/backports.py - About 3 hrs to fix

Function intersect_generators has a Cognitive Complexity of 28 (exceeds 10 allowed). Consider refactoring.
Open

def intersect_generators(*iterables, allow_duplicates: bool = False):
"""Generator of intersect iterables.
 
Yield items only if they are yielded by all iterables. zip_longest
is used to retrieve items from all iterables in parallel, so that
Severity: Minor
Found in pywikibot/tools/itertools.py - About 3 hrs to fix

Function translateAndCapitalizeNamespaces has a Cognitive Complexity of 28 (exceeds 10 allowed). Consider refactoring.
Open

def translateAndCapitalizeNamespaces(self, text: str) -> str:
"""Use localized namespace names.
 
.. versionchanged:: 7.4
No longer expect a specific namespace alias for File:
Severity: Minor
Found in pywikibot/cosmetic_changes.py - About 3 hrs to fix

TestFactoryGenerator has 37 functions (exceeds 30 allowed). Consider refactoring.
Open

class TestFactoryGenerator(DefaultSiteTestCase):
 
"""Test pagegenerators.GeneratorFactory."""
 
def test_combined_generator(self):
Severity: Minor
Found in tests/pagegenerators_tests.py - About 3 hrs to fix

    Function toJSON has a Cognitive Complexity of 27 (exceeds 10 allowed). Consider refactoring.
    Open

    def toJSON(self, diffto: dict | None = None) -> dict:
    """Create JSON suitable for Wikibase API.
     
    When diffto is provided, JSON representing differences
    to the provided data is created.
    Severity: Minor
    Found in pywikibot/page/_collections.py - About 3 hrs to fix

    Function __enter__ has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring.
    Open

    def __enter__(self):
    """Enter the context manager."""
    def detailed_show_warning(*args, **kwargs):
    """Replacement handler for warnings.showwarning."""
    warn_msg = warnings.WarningMessage(*args, **kwargs)
    Severity: Minor
    Found in tests/utils.py - About 2 hrs to fix

    Function find_file_on_commons has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring.
    Open

    def find_file_on_commons(self, local_file_page):
    """Find filename on Commons."""
    for template_name, params in local_file_page.templatesWithParams():
    if template_name not in self.nc_templates:
    continue
    Severity: Minor
    Found in scripts/nowcommons.py - About 2 hrs to fix

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

    Function cleanUpLinks has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring.
    Open

    def cleanUpLinks(self, text: str) -> str:
    """Tidy up wikilinks found in a string.
     
    This function will:
     
     
    Severity: Minor
    Found in pywikibot/cosmetic_changes.py - About 2 hrs to fix

    Function fromDBName has a Cognitive Complexity of 26 (exceeds 10 allowed). Consider refactoring.
    Open

    def fromDBName( # noqa: N802
    dbname: str,
    site: BaseSite | None = None
    ) -> BaseSite:
    """Create a site from a database name using the sitematrix.
    Severity: Minor
    Found in pywikibot/site/_apisite.py - About 2 hrs to fix

    File _datasite.py has 932 lines of code (exceeds 900 allowed). Consider refactoring.
    Open

    """Objects representing API interface to Wikibase site."""
    #
    # (C) Pywikibot team, 2012-2024
    #
    # Distributed under the terms of the MIT license.
    Severity: Major
    Found in pywikibot/site/_datasite.py - About 2 hrs to fix

      Function generator has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
      Open

      def generator(self):
      """Inner generator.
       
      .. versionchanged:: 7.6
      changed from iterator method to generator property
      Severity: Minor
      Found in pywikibot/comms/eventstreams.py - About 2 hrs to fix

      Function _get_siteinfo has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
      Open

      def _get_siteinfo(self, prop, expiry) -> dict:
      """Retrieve a siteinfo property.
       
      All properties which the site doesn't
      support contain the default value. Because pre-1.12 no data was
      Severity: Minor
      Found in pywikibot/site/_siteinfo.py - About 2 hrs to fix

      Function pywikibot_script_docstring_fixups has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
      Open

      def pywikibot_script_docstring_fixups(app, what, name, obj, options, lines):
      """Pywikibot specific conversions."""
      from scripts.cosmetic_changes import warning
       
      if what != 'module' or 'scripts.' not in name:
      Severity: Minor
      Found in docs/conf.py - About 2 hrs to fix
      Severity
      Category
      Status
      Source
      Language