Showing 286 of 616 total issues
Avoid deeply nested control flow statements. Open
Open
if hunk.reviewed == Hunk.PENDING:
hunk.reviewed = Hunk.NOT_APPR
elif choice in ['a', 'd']:
Avoid deeply nested control flow statements. Open
Open
if error.code == 'stashfailed' \
and 'offset' in error.other:
# TODO: Ask MediaWiki to change this
# ambiguous error code.
Avoid deeply nested control flow statements. Open
Open
if callable(ignore_warnings):
restart = False
if 'offset' not in data:
# This is a result of a warning in the
# first chunk. The chunk is not actually
Function merge_query_arguments
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
Open
def merge_query_arguments(self,
database_id: int | None = None,
schema_name: str | None = None,
site: BaseSite = None) -> tuple(int, str):
"""Determine and validate the database_id and schema_name.
- 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
Open
for ref_propid, reference in ref_grp['snaks'].items():
for ref_index, ref_stat in enumerate(reference):
target_ref_grp = claim.sources[ref_grp_idx]
target_ref_prop = target_ref_grp[ref_propid]
target_ref = target_ref_prop[ref_index]
Avoid deeply nested control flow statements. Open
Open
if self.sametitle(key, pagedata['title']):
cache[pagedata['title']] = value
break
else:
Avoid deeply nested control flow statements. Open
Open
if page.title(with_ns=False) == self._base:
what_links_here.remove(page)
self._index = (page, what_links_here)
break
Avoid deeply nested control flow statements. Open
Open
if poll:
# run a poll; not possible in first iteration
assert file_key
req = self.site.simple_request(
action='upload',
Avoid deeply nested control flow statements. Open
Open
if hunk.reviewed == Hunk.PENDING:
hunk.reviewed = \
Hunk.APPR if choice == 'a' else Hunk.NOT_APPR
position = find_pending(0, position)
Function preloadpages
has 9 arguments (exceeds 7 allowed). Consider refactoring. Open
Open
def preloadpages(
Avoid deeply nested control flow statements. Open
Open
if family == 'wiki':
family = 'wikipedia'
return pywikibot.Site(code, family)
Avoid deeply nested control flow statements. Open
Open
if 'offset' in data:
new_offset = int(data['offset'])
if offset + len(chunk) != new_offset:
pywikibot.log(
f'Old offset: {offset}; Returned '
Function pagereferences
has 9 arguments (exceeds 7 allowed). Consider refactoring. Open
Open
def pagereferences(
Avoid deeply nested control flow statements. Open
Open
with open(include) as g:
desc.append(re.sub(pattern[0], pattern[1], g.read()))
else: # pragma: no cover
Function replaceExcept
has 9 arguments (exceeds 7 allowed). Consider refactoring. Open
Open
def replaceExcept(text: str,
Function addDirectedEdge
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
Open
def addDirectedEdge(self, page: pywikibot.page.Page,
refPage: pywikibot.page.Page) -> None:
"""Add a directed edge from refPage to page."""
assert self.graph is not None
# if page was given as a hint, referrers would be [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
Consider simplifying this complex logical expression. Open
Open
if '.' in t and (t in ('.', '..')
or t.startswith(('./', '../'))
or '/./' in t
or '/../' in t
or t.endswith(('/.', '/..'))):
Consider simplifying this complex logical expression. Open
Open
if arg == 'noauto':
self.auto = False
elif arg == 'hint':
self.hints.append(value)
elif arg == 'hintfile':
Consider simplifying this complex logical expression. Open
Open
if new_page_title == link_text and not section \
or self.opt.overwrite:
newlink = f'[[{new_page_title}]]'
# check if we can create a link with trailing characters instead of
# a pipelink
Consider simplifying this complex logical expression. Open
Open
if opt == 'start':
options[opt] = value or pywikibot.input(
'From which title do you want to continue?')
elif opt == 'save':
options[opt] = value or pywikibot.input(