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:
ProofreadPage
has 38 functions (exceeds 30 allowed). Consider refactoring. Open
class ProofreadPage(pywikibot.Page):
"""ProofreadPage page used in MediaWiki ProofreadPage extension."""
WITHOUT_TEXT = 0
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>,
- Read upRead up
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] = {}
- Read upRead up
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,
- Read upRead up
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
Avoid too many return
statements within this function. Open
return error, parser_func(_text)
TODO found Open
# TODO: check should be made to be consistent with Proofread Extension
- Exclude checks
TODO found Open
# TODO: align this value with ProofreadPage.ql
- Exclude checks
TODO found Open
# TODO: check should be made to be consistent with Proofread Extension
- Exclude checks
TODO found Open
""" # TODO: remove once bug is fixed.
- Exclude checks
TODO found Open
# TODO: add logic to validate ql value change, considering
- Exclude checks
TODO found Open
# TODO: This is a workaround for T128994. Remove once bug is fixed.
- Exclude checks