wikimedia/pywikibot

View on GitHub
scripts/checkimages.py

Summary

Maintainability
D
2 days
Test Coverage

File checkimages.py has 1353 lines of code (exceeds 900 allowed). Consider refactoring.
Open

#!/usr/bin/env python3
"""Script to check recently uploaded files.

This script checks if a file description is present and if there are
other problems in the image's description.
Severity: Major
Found in scripts/checkimages.py - About 1 day to fix

    Function put_mex_in_talk has a Cognitive Complexity of 33 (exceeds 10 allowed). Consider refactoring.
    Open

        def put_mex_in_talk(self) -> None:
            """Function to put the warning in talk page of the uploader.
    
            When the bot find that the usertalk is empty it adds the welcome
            message first. The messages are imported from welcome.py script.
    Severity: Minor
    Found in scripts/checkimages.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 check_image_on_commons has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
    Open

        def check_image_on_commons(self) -> bool:
            """Checking if the file is on commons."""
            pywikibot.info(f'Checking if [[{self.image_name}]] is on commons...')
            try:
                hash_found = self.image.latest_file_info.sha1
    Severity: Minor
    Found in scripts/checkimages.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 report has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
    Open

        def report(
            self,
            newtext,
            image_to_report,
            notification=None,
    Severity: Minor
    Found in scripts/checkimages.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 report has 8 arguments (exceeds 7 allowed). Consider refactoring.
    Open

        def report(
    Severity: Major
    Found in scripts/checkimages.py - About 35 mins to fix

      TODO found
      Open

              # TODO: enhance and use textlib.MultiTemplateMatchBuilder
      Severity: Minor
      Found in scripts/checkimages.py by fixme

      There are no issues that match your filters.

      Category
      Status