Showing 286 of 616 total issues
Function from_url
has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring. Open
def from_url(self, url: str) -> str | None:
"""Return whether this family matches the given url.
It is first checking if a domain of this family is in the domain of
the URL. If that is the case it's checking all codes and verifies that
- 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 RepeatingGenerator
has a Cognitive Complexity of 18 (exceeds 10 allowed). Consider refactoring. Open
def RepeatingGenerator(
generator: Callable[..., Iterable[pywikibot.page.BasePage]],
key_func: Callable[[pywikibot.page.BasePage], Any] = lambda x: x,
sleep_duration: int = 60,
total: int | 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
Function run
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def run(self) -> bool:
"""Run the installer script.
:return: True if no error occurs, else 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 run
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def run(self) -> None:
"""Run thread."""
while not self.killed:
if not self.queue:
if self.finishing:
- 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 treat
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def treat(self, page) -> None:
"""Process one page."""
# Load the page's text from the wiki
new_text = page.text
raw_text = textlib.removeDisabledParts(new_text)
- 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 generator
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def generator(self) -> Generator[pywikibot.User, None, None]:
"""Retrieve new users."""
while True:
if globalvar.timeoffset != 0:
start = self.site.server_time() - timedelta(
- 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 __init__
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def __init__(self, code: str, fam=None, user=None) -> None:
"""Initializer.
:param code: the site's language code
:type code: str
- 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 main
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def main(*args: str) -> None:
"""Print pywikibot version and important settings.
.. versionchanged:: 9.1.2
usernames are not printed with ``-nouser`` option.
- 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
has a Cognitive Complexity of 17 (exceeds 10 allowed). Consider refactoring. Open
def get(
self,
key: str,
get_default: bool = True,
cache: bool = True,
- 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
if (not self.workonme # we don't work on it anyway
or not self.untranslated and not self.conf.askhints
or self.hintsAsked
or not self.origin
or not self.origin.exists()
Function testNamespaceCompare
has 38 lines of code (exceeds 30 allowed). Consider refactoring. Open
def testNamespaceCompare(self):
"""Test Namespace comparisons."""
a = Namespace(id=0, canonical_name='')
self.assertEqual(a, 0)
Function test_last_match_and_replace
has 37 lines of code (exceeds 30 allowed). Consider refactoring. Open
def test_last_match_and_replace(self):
"""Test that pattern matches and removes items correctly."""
txt_with_one_match = 'this string has 3000, 1999 and 3000 in it'
txt_with_two_match = 'this string has 1998, 1999 and 3000 in it'
txt_with_no_match = 'this string has no match'
Function test_WbTime_normalization
has 37 lines of code (exceeds 30 allowed). Consider refactoring. Open
def test_WbTime_normalization(self):
"""Test WbTime normalization."""
repo = self.get_repo()
# flake8 is being annoying, so to reduce line length, I'll make
# some aliases here
Function _test_fromPage_noitem
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def _test_fromPage_noitem(self, link):
"""Helper function to test a page without an associated item.
It tests two of the ways to fetch an item:
1. the Page already has props, which should contain an item id if
- 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 move_contents
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def move_contents(self, old_cat_title: str, new_cat_title: str,
edit_summary: str) -> tuple[int, int]:
"""The worker function that moves pages out of oldCat into newCat."""
old_cat = pywikibot.Category(self.site, self.catprefix + old_cat_title)
new_cat = pywikibot.Category(self.site, self.catprefix + new_cat_title)
- 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 guess_reason_for_deletion
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def guess_reason_for_deletion(self, page):
"""Find a default reason for speedy deletion."""
# TODO: The following check loads the page 2 times.
# Find a better way to do it.
if page.isTalkPage() and (page.toggleTalkPage().isRedirectPage()
- 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 check_page
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def check_page(self, pagename) -> None:
"""Check one page."""
pywikibot.info('\nChecking ' + pagename)
page1 = Page(self.original, pagename)
txt1 = page1.text
- 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 newest_pages
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def newest_pages(
self,
total: int | None = None
) -> Generator[Page, None, None]:
"""Return pages in a category ordered by the creation date.
- 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_best_claim
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def get_best_claim(self, prop: str):
"""Return the first best Claim for this page.
Return the first 'preferred' ranked Claim specified by Wikibase
property or the first 'normal' one otherwise.
- 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 main
has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring. Open
def main(*args: str) -> None:
"""Process command line arguments and invoke bot.
If args is an empty list, sys.argv is used.
- 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"