wikimedia/pywikibot

View on GitHub
pywikibot/proofreadpage.py

Summary

Maintainability
D
1 day
Test Coverage

File proofreadpage.py has 1032 lines of code (exceeds 900 allowed). Consider refactoring.
Open

"""Objects used with ProofreadPage Extension.

OCR support of page scans via:

- Wikimedia OCR, see:
Severity: Major
Found in pywikibot/proofreadpage.py - About 5 hrs to fix

    ProofreadPage has 38 functions (exceeds 30 allowed). Consider refactoring.
    Open

    class ProofreadPage(pywikibot.Page):
    
        """ProofreadPage page used in MediaWiki ProofreadPage extension."""
    
        WITHOUT_TEXT = 0
    Severity: Minor
    Found in pywikibot/proofreadpage.py - About 3 hrs to fix

      Function index has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
      Open

          def index(self) -> IndexPage | None:
              """Get the Index page which contains ProofreadPage.
      
              If there are many Index pages link to this ProofreadPage, and
              the ProofreadPage is titled Page:<index title>/<page number>,
      Severity: Minor
      Found in pywikibot/proofreadpage.py - About 2 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 _get_page_mappings has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
      Open

          def _get_page_mappings(self) -> None:
              """Associate label and number for each page linked to the index."""
              # Clean cache, if any.
              self._page_from_numbers = {}
              self._numbers_from_page: dict[pywikibot.page.Page, int] = {}
      Severity: Minor
      Found in pywikibot/proofreadpage.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 _ocr_callback has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def _ocr_callback(
              self,
              cmd_uri: str,
              parser_func: Callable[[str], str] | None = None,
              ocr_tool: str | None = None,
      Severity: Minor
      Found in pywikibot/proofreadpage.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 page.title(with_ns=False) == self._base:
                                  what_links_here.remove(page)
                                  self._index = (page, what_links_here)
                                  break
      
      
      Severity: Major
      Found in pywikibot/proofreadpage.py - About 45 mins to fix

        Avoid too many return statements within this function.
        Open

                return error, parser_func(_text)
        Severity: Major
        Found in pywikibot/proofreadpage.py - About 30 mins to fix

          TODO found
          Open

                  # TODO: check should be made to be consistent with Proofread Extension
          Severity: Minor
          Found in pywikibot/proofreadpage.py by fixme

          TODO found
          Open

                  # TODO: align this value with ProofreadPage.ql
          Severity: Minor
          Found in pywikibot/proofreadpage.py by fixme

          TODO found
          Open

                  # TODO: check should be made to be consistent with Proofread Extension
          Severity: Minor
          Found in pywikibot/proofreadpage.py by fixme

          TODO found
          Open

              """  # TODO: remove once bug is fixed.
          Severity: Minor
          Found in pywikibot/proofreadpage.py by fixme

          TODO found
          Open

                  # TODO: add logic to validate ql value change, considering
          Severity: Minor
          Found in pywikibot/proofreadpage.py by fixme

          TODO found
          Open

                  # TODO: This is a workaround for T128994. Remove once bug is fixed.
          Severity: Minor
          Found in pywikibot/proofreadpage.py by fixme

          There are no issues that match your filters.

          Category
          Status