wikimedia/pywikibot

View on GitHub
scripts/patrol.py

Summary

Maintainability
C
1 day
Test Coverage

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

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 main has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
Open

def main(*args: str) -> None:
    """Process command line arguments and invoke PatrolBot."""
    # This factory is responsible for processing command line arguments
    # that are also used by other scripts and that determine on which pages
    # to work on.
Severity: Minor
Found in scripts/patrol.py - About 2 hrs 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 api_feed_repeater has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
Open

def api_feed_repeater(
    gen, *,
    delay: float = 60,
    repeat: bool = False,
    namespaces=None,
Severity: Minor
Found in scripts/patrol.py - About 45 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

    hack found
    Open

                            verbose_output('Whitelist prefixindex hack for: '
    Severity: Minor
    Found in scripts/patrol.py by fixme

    There are no issues that match your filters.

    Category
    Status