pywikibot/textlib.py
File textlib.py
has 1662 lines of code (exceeds 900 allowed). Consider refactoring. Open
Open
"""Functions for manipulating wiki-text."""
#
# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
Function replaceExcept
has a Cognitive Complexity of 34 (exceeds 10 allowed). Consider refactoring. Open
Open
def replaceExcept(text: str,
old: str | Pattern[str],
new: str | Callable[[Match[str]], str],
exceptions: SequenceType[str | Pattern[str]],
caseInsensitive: bool = False,
- 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_regexes
has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring. Open
Open
def get_regexes(
keys: str | Iterable[str],
site: pywikibot.site.BaseSite | None = None
) -> list[Pattern[str]]:
"""Fetch compiled regexes.
- 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 replaceExcept
has 9 arguments (exceeds 7 allowed). Consider refactoring. Open
Open
def replaceExcept(text: str,
TODO found Open
Open
# TODO: add option for template to be None to match any template
- Exclude checks
TODO found Open
Open
# TODO: Work on the link within the label too
- Exclude checks
TODO found Open
Open
# TODO: There is no semantic difference between hyphens and
- Exclude checks
TODO found Open
Open
# TODO: currently, we do not have any, but BCP 47 allows digits, and
- Exclude checks
TODO found Open
Open
# TODO: handle nested tables.
- Exclude checks
hack found Open
Open
# it is a little hack to make \n work. It would be better
- Exclude checks
TODO found Open
Open
# TODO: add ability to also match contents within the template
- Exclude checks
TODO found Open
Open
# TODO: merge regex with NESTED_TEMPLATE_REGEX
- Exclude checks
TODO found Open
Open
# TODO: Unclosed link label, what happens there?
- Exclude checks
TODO found Open
Open
# TODO: This must also compare everything that was used as a
- Exclude checks