wikimedia/pywikibot

View on GitHub

Showing 283 of 613 total issues

Function process_desc_template has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
Open

def process_desc_template(
self,
template: mwparserfromhell.nodes.template.Template
) -> bool:
"""Process description template.
Severity: Minor
Found in scripts/commons_information.py - About 1 hr to fix

Function get_redirects_from_dump has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
Open

def get_redirects_from_dump(
self,
alsoGetPageTitles: bool = False
) -> tuple[dict[str, str], set[str]]:
"""Extract redirects from dump.
Severity: Minor
Found in scripts/redirect.py - About 1 hr to fix

Function read_file_content has a Cognitive Complexity of 20 (exceeds 10 allowed). Consider refactoring.
Open

def read_file_content(self, file_url: str):
"""Return name of temp file in which remote file is saved."""
pywikibot.info('Reading file ' + file_url)
 
handle, tempname = tempfile.mkstemp()
Severity: Minor
Found in pywikibot/specialbots/_upload.py - About 1 hr to fix

Function __init__ has 18 arguments (exceeds 7 allowed). Consider refactoring.
Open

def __init__(self, oldcat,
Severity: Major
Found in scripts/category.py - About 1 hr to fix

    Function parse has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
    Open

    def parse(self):
    """Parse wikitext of the link.
     
    Called internally when accessing attributes.
    """
    Severity: Minor
    Found in pywikibot/page/_links.py - About 1 hr to fix

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

    def __init__(self, generator, templates: dict, **kwargs) -> None:
    """Initializer.
     
    :param generator: the pages to work on
    :type generator: iterable
    Severity: Minor
    Found in scripts/template.py - About 1 hr to fix

    Function format_diff has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
    Open

    def format_diff(self) -> Iterable[str]:
    """Color diff lines."""
    diff = iter(self.diff)
     
    fmt: str | None = ''
    Severity: Minor
    Found in pywikibot/diff.py - About 1 hr to fix

    Function preload_entities has a Cognitive Complexity of 19 (exceeds 10 allowed). Consider refactoring.
    Open

    def preload_entities(
    self,
    pagelist: Iterable[pywikibot.page.WikibaseEntity
    | pywikibot.page.Page],
    groupsize: int = 50
    Severity: Minor
    Found in pywikibot/site/_datasite.py - About 1 hr to fix

    Function recentchanges has 17 arguments (exceeds 7 allowed). Consider refactoring.
    Open

    def recentchanges(
    Severity: Major
    Found in pywikibot/site/_generators.py - About 1 hr to fix

      Function __init__ has 16 arguments (exceeds 7 allowed). Consider refactoring.
      Open

      def __init__(self, url: list[str] | str, *,
      Severity: Major
      Found in pywikibot/specialbots/_upload.py - About 1 hr to fix

        Function __init__ has 45 lines of code (exceeds 30 allowed). Consider refactoring.
        Open

        def __init__(self, parent=None, **kwargs) -> None:
        """Initializer."""
        for module in (idlelib, tkinter):
        if isinstance(module, ImportError):
        raise module
        Severity: Minor
        Found in pywikibot/userinterfaces/gui.py - About 1 hr to fix

          Function get_item_list has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
          Open

          def get_item_list(item_name: str,
          instance_id: str | set[str] | list[str]) -> set[str]:
          """Get list of items by name, belonging to an instance (list).
           
          Normally there should have one single best match. The caller should
          Severity: Minor
          Found in scripts/create_isbn_edition.py - About 1 hr to fix

          Function allow_asynchronous has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
          Open

          def allow_asynchronous(func):
          """Decorator to make it possible to run a BasePage method asynchronously.
           
          This is done when the method is called with kwarg
          :code:`asynchronous=True`. Optionally, you can also provide kwarg
          Severity: Minor
          Found in pywikibot/page/_decorators.py - About 1 hr to fix

          Function process_entries has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
          Open

          def process_entries(cache_path, func, use_accesstime: bool | None = None,
          output_func=None, action_func=None, *,
          tests: int | None = None):
          """Check the contents of the cache.
           
           
          Severity: Minor
          Found in scripts/maintenance/cache.py - About 1 hr to fix

          Function main has a Cognitive Complexity of 18 (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/djvutext.py - About 1 hr to fix

          Function RepeatingGenerator has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
          Open

          def RepeatingGenerator(
          generator: Callable[..., Iterable[pywikibot.page.BasePage]],
          key_func: Callable[[pywikibot.page.BasePage], Any] = lambda x: x,
          sleep_duration: int = 60,
          total: int | None = None,
          Severity: Minor
          Found in pywikibot/pagegenerators/__init__.py - About 1 hr to fix

          Function from_url has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
          Open

          def from_url(self, url: str) -> str | None:
          """Return whether this family matches the given url.
           
          It is first checking if a domain of this family is in the domain of
          the URL. If that is the case it's checking all codes and verifies that
          Severity: Minor
          Found in pywikibot/family.py - About 1 hr to fix

          Function _post_process has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
          Open

          def _post_process(prop, data) -> None:
          """Do some default handling of data. Directly modifies data."""
          # Be careful with version tests inside this here as it might need to
          # query this method to actually get the version number
           
           
          Severity: Minor
          Found in pywikibot/site/_siteinfo.py - About 1 hr to fix

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

          def __init__(self, site=None,
          mime: dict | None = None,
          throttle: bool = True,
          max_retries: int | None = None,
          retry_wait: int | None = None,
          Severity: Minor
          Found in pywikibot/data/api/_requests.py - About 1 hr to fix

          Function _print has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring.
          Open

          def _print(self, text, target_stream) -> None:
          """Write the text to the target stream handling the colors."""
          colorized = (config.colorized_output
          and self.support_color(target_stream))
          colored_line = False
          Severity: Minor
          Found in pywikibot/userinterfaces/terminal_interface_base.py - About 1 hr to fix
          Severity
          Category
          Status
          Source
          Language