wikimedia/pywikibot

View on GitHub
scripts/maintenance/cache.py

Summary

Maintainability
C
1 day
Test Coverage

Function process_entries has a Cognitive Complexity of 41 (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 5 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 37 (exceeds 10 allowed). Consider refactoring.
Open

def main():
    """Process command line arguments and invoke bot."""
    local_args = pywikibot.handle_args()
    cache_paths = None
    delete = False
Severity: Minor
Found in scripts/maintenance/cache.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 parse_key has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
Open

    def parse_key(self):
        """Parse the key loaded from the cache entry."""
        # find the start of the first parameter
        start = self.key.index('(')
        # find the end of the first object
Severity: Minor
Found in scripts/maintenance/cache.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

There are no issues that match your filters.

Category
Status