Sorry, data for that comparison is no longer available.

wikimedia/pywikibot

View on GitHub
scripts/replace.py

Summary

Maintainability
B
5 hrs
Test Coverage

File replace.py has 904 lines of code (exceeds 900 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
r"""
This bot will make direct text replacements.

It will retrieve information on which pages might need changes either from
Severity: Major
Found in scripts/replace.py - About 2 hrs to fix

    Function apply_replacements has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring.
    Open

        def apply_replacements(self, original_text, applied, page=None):
            """
            Apply all replacements to the given text.
    
            :rtype: str, set
    Severity: Minor
    Found in scripts/replace.py - About 1 hr 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 __iter__ has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
    Open

        def __iter__(self):
            """Iterator method."""
            try:
                for entry in self.parser:
                    if self.skipping:
    Severity: Minor
    Found in scripts/replace.py - About 1 hr 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 isTitleExcepted has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
    Open

        def isTitleExcepted(self, title, exceptions=None) -> bool:
            """Return True if one of the exceptions applies for the given title."""
            if exceptions is None:
                exceptions = self.exceptions
            if 'title' in exceptions:
    Severity: Minor
    Found in scripts/replace.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

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

        def isTitleExcepted(self, title) -> bool:
            """Return True if one of the exceptions applies for the given title."""
            if 'title' in self.exceptions:
                for exc in self.exceptions['title']:
                    if exc.search(title):
    Severity: Minor
    Found in scripts/replace.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

    There are no issues that match your filters.

    Category
    Status