wikimedia/pywikibot

View on GitHub
scripts/category.py

Summary

Maintainability
D
2 days
Test Coverage

File category.py has 1360 lines of code (exceeds 900 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
"""Script to manage categories.

Syntax:

Severity: Major
Found in scripts/category.py - About 1 day to fix

    Function __init__ has 18 arguments (exceeds 7 allowed). Consider refactoring.
    Open

        def __init__(self, oldcat,
    Severity: Major
    Found in scripts/category.py - About 1 hr to fix

      Function list_categories has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
      Open

                  def list_categories(cat_list, prefix: str = '') -> None:
                      """Output categories in one or two columns.
      
                      Determine whether the list contains long or short
                      category titles and output category titles as enumerated
      Severity: Minor
      Found in scripts/category.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 __init__ has 12 arguments (exceeds 7 allowed). Consider refactoring.
      Open

          def __init__(self, cat_title: str | None, list_title: str | None,
      Severity: Major
      Found in scripts/category.py - About 1 hr to fix

        Function determine_type_target has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
        Open

            def determine_type_target(
                self,
                page: pywikibot.Page
            ) -> pywikibot.Page | None:
                """
        Severity: Minor
        Found in scripts/category.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 None
        Severity: Major
        Found in scripts/category.py - About 30 mins to fix

          TODO found
          Open

              # TODO: use options instead following variables:
          Severity: Minor
          Found in scripts/category.py by fixme

          TODO found
          Open

                  TODO: decide if/how to enable/disable this feature.
          Severity: Minor
          Found in scripts/category.py by fixme

          There are no issues that match your filters.

          Category
          Status