wikimedia/pywikibot

View on GitHub
scripts/archivebot.py

Summary

Maintainability
C
1 day
Test Coverage

Function analyze_page has a Cognitive Complexity of 34 (exceeds 10 allowed). Consider refactoring.
Open

    def analyze_page(self) -> set[tuple[str, str]]:
        """Analyze DiscussionPage."""
        max_size = self.get_attr('maxarchivesize')
        max_arch_size = str2size(max_size)
        if not max_arch_size[0]:
Severity: Minor
Found in scripts/archivebot.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 load_page has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def load_page(self) -> None:
        """Load the page to be archived and break it up into threads.

        .. versionchanged:: 7.6
           If `-keep` option is given run through all threads and set
Severity: Minor
Found in scripts/archivebot.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

Avoid deeply nested control flow statements.
Open

                    if PYTHON_VERSION < (3, 9):
                        futures.append(future)

Severity: Major
Found in scripts/archivebot.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if not exiting.is_set():
                            continue
    
    
    Severity: Major
    Found in scripts/archivebot.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if PYTHON_VERSION < (3, 9):
                              canceled = sum(future.cancel() for future in futures)
                          else:
                              executor.shutdown(cancel_futures=True)
      
      
      Severity: Major
      Found in scripts/archivebot.py - About 45 mins to fix

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

            def load_config(self) -> None:
                """Load and validate archiver template."""
                pywikibot.info(
                    f'Looking for: {{{{{self.tpl.title()}}}}} in {self.page}')
        
        
        Severity: Minor
        Found in scripts/archivebot.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

        TODO found
        Open

                    # TODO: Make an option so that unstamped (unsigned) posts get
        Severity: Minor
        Found in scripts/archivebot.py by fixme

        TODO found
        Open

                    # TODO: handle unsigned
        Severity: Minor
        Found in scripts/archivebot.py by fixme

        TODO found
        Open

                        # TODO: handle unsigned or archived by template
        Severity: Minor
        Found in scripts/archivebot.py by fixme

        FIXME found
        Open

                    whys.add(why)  # FIXME: we don't know if we ever archive anything
        Severity: Minor
        Found in scripts/archivebot.py by fixme

        TODO found
        Open

                # TODO: handle marked with template
        Severity: Minor
        Found in scripts/archivebot.py by fixme

        There are no issues that match your filters.

        Category
        Status