wikimedia/pywikibot

View on GitHub

Showing 728 of 728 total issues

Function _select_action has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def _select_action(page):
        """Manage interactive choices."""

        def create_new_title_change(page, new_title=None):
            """Change helper function."""
Severity: Minor
Found in scripts/movepages.py - About 35 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 parse_site has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def parse_site(self) -> tuple:
        """
        Parse only enough text to determine which site the link points to.

        This method does not parse anything after the first ":"; links
Severity: Minor
Found in pywikibot/page/_links.py - About 35 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 resolve has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def resolve(self, identifiers) -> list[Namespace]:
        """
        Resolve namespace identifiers to obtain Namespace objects.

        Identifiers may be any value for which int() produces a valid
Severity: Minor
Found in pywikibot/site/_namespace.py - About 35 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 check_response has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

def check_response(response):
    """Raise ClientError or ServerError depending on http status.

    .. versionadded:: 3.0
    .. versionchanged:: 7.0
Severity: Minor
Found in pywikibot/site_detect.py - About 35 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 normalizeData has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def normalizeData(cls, data: dict) -> dict:
        """Helper function to expand data into the Wikibase API structure.

        .. versionchanged:: 7.7
           raises TypeError if *data* value is not a list.
Severity: Minor
Found in pywikibot/page/_collections.py - About 35 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 _handle_query_limit has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def _handle_query_limit(self, prev_limit, new_limit, had_data):
        """Handle query limit."""
        if self.query_limit is None or self.limited_module is None:
            return prev_limit, new_limit

Severity: Minor
Found in pywikibot/data/api/_generators.py - About 35 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 __setitem__ has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def __setitem__(self, name, value):
        """Set option to enabled, disabled or neither."""
        if value is True:
            if self._site_set and name not in self._valid_enable:
                raise KeyError(f'Invalid name "{name}"')
Severity: Minor
Found in pywikibot/data/api/_optionset.py - About 35 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 __init__ has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def __init__(self,
                 endpoint: str | None = None,
                 entity_url: str | None = None, repo=None,
                 max_retries: int | None = None,
                 retry_wait: float | None = None) -> None:
Severity: Minor
Found in pywikibot/data/sparql.py - About 35 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 logoutput has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

def logoutput(msg: Any,
              *args: Any,
              level: int = INFO,
              **kwargs: Any) -> None:
    """Format output and send to the logging module.
Severity: Minor
Found in pywikibot/logging.py - About 35 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 pagebacklinks has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def pagebacklinks(
        self,
        page: pywikibot.Page,
        *,
        follow_redirects: bool = False,
Severity: Minor
Found in pywikibot/site/_generators.py - About 35 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 run has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def run(self) -> None:
        """Run the generator and store the results on the queue."""
        iterable = any(hasattr(self.generator, key)
                       for key in ('__iter__', '__getitem__'))
        if iterable and not self.args and not self.kwargs:
Severity: Minor
Found in pywikibot/tools/threading.py - About 35 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 __init__ has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
Open

    def __init__(self, url: list[str] | str, *,
                 url_encoding=None,
                 description: str = '',
                 use_filename=None,
                 keep_filename: bool = False,
Severity: Minor
Found in pywikibot/specialbots/_upload.py - About 35 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

Avoid too many return statements within this function.
Open

        return False
Severity: Major
Found in scripts/patrol.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return self.checkCommonscatLink(
    Severity: Major
    Found in scripts/commonscat.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                  return ''
      Severity: Major
      Found in scripts/commonscat.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return None
        Severity: Major
        Found in scripts/category.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return commonsPage.title(with_ns=False)
          Severity: Major
          Found in scripts/commonscat.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return True
            Severity: Major
            Found in make_dist.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                      return False
              Severity: Major
              Found in scripts/revertbot.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                            return
                Severity: Major
                Found in scripts/category_redirect.py - About 30 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language