scripts/solve_disambiguation.py
File solve_disambiguation.py
has 1061 lines of code (exceeds 900 allowed). Consider refactoring. Open
Open
#!/usr/bin/env python3
"""
Script to help a human solve disambiguations by presenting a set of options.
Specify the disambiguation page on the command line.
Function treat_disamb_only
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
Open
def treat_disamb_only(self, ref_page, disamb_page) -> str:
"""Resolve the links to disamb_page but don't look for its redirects.
:param disamb_page: the disambiguation page or redirect we don't want
anything to link to
- 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
Consider simplifying this complex logical expression. Open
Open
if replaceit and trailing_chars:
newlink = f'[[{new_page_title}{section}]]{trailing_chars}'
elif replaceit or (new_page_title == link_text
and not section):
newlink = f'[[{new_page_title}]]'
Function __iter__
has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring. Open
Open
def __iter__(self) -> Generator[pywikibot.Page, None, None]:
"""Yield pages."""
# TODO: start yielding before all referring pages have been found
refs = list(self.page.getReferences(with_template_inclusion=False,
namespaces=0 if self.main_only
- 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
TODO found Open
Open
# TODO: start yielding before all referring pages have been found
- Exclude checks
TODO found Open
Open
# TODO: break this function up into subroutines!
- Exclude checks
TODO found Open
Open
# TODO: Output context on each question
- Exclude checks