Showing 616 of 616 total issues
Avoid deeply nested control flow statements. Open
if key == '@metadata':
continue
self.assertTrue(
Avoid deeply nested control flow statements. Open
if tu:
# no changes needed, better to revert the old text.
text = oldtext
else:
Function check_image_on_commons
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def check_image_on_commons(self) -> bool:
"""Checking if the file is on commons."""
pywikibot.info(f'Checking if [[{self.image_name}]] is on commons...')
try:
hash_found = self.image.latest_file_info.sha1
- 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 tu:
# no changes needed, better to revert the old text.
text = oldtext
else:
Function set_redirect_target
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def set_redirect_target(
self,
target_page: pywikibot.Page | str,
create: bool = False,
force: 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 getPDFTitle
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def getPDFTitle(ref, response) -> None:
"""Use pdfinfo to retrieve title from a PDF."""
# pdfinfo is Unix-only
pywikibot.info('Reading PDF file...')
infile = 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 get
has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring. Open
def get(self, force: bool = False) -> dict:
"""Fetch all MediaInfo entity data and cache it.
.. note:: dicts returned by this method are references to content
of this entity and their modifying may indirectly cause
- 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 watchlist_revs
has 9 arguments (exceeds 7 allowed). Consider refactoring. Open
def watchlist_revs(
Avoid deeply nested control flow statements. Open
for qual_index, qual_statement in enumerate(qualifier):
target_qual_prop = claim.qualifiers[qual_propid]
target_qual = target_qual_prop[qual_index]
target_qual.hash = qual_statement['hash']
updated_references = statement.get('references', [])
Similar blocks of code found in 5 locations. Consider refactoring. Open
ts1 = pywikibot.Timestamp(
year=2022, month=12, day=21, hour=13,
tzinfo=datetime.timezone(datetime.timedelta(hours=-5)))
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 43.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid deeply nested control flow statements. Open
if hunk.reviewed == Hunk.PENDING:
hunk.reviewed = Hunk.NOT_APPR
elif choice in ['a', 'd']:
Avoid deeply nested control flow statements. 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
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
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
Similar blocks of code found in 5 locations. Consider refactoring. Open
ts1 = pywikibot.Timestamp(
year=2022, month=12, day=21, hour=13,
tzinfo=datetime.timezone(datetime.timedelta(hours=-5)))
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 43.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Avoid deeply nested control flow statements. 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
if self.sametitle(key, pagedata['title']):
cache[pagedata['title']] = value
break
else:
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 deeply nested control flow statements. Open
if poll:
# run a poll; not possible in first iteration
assert file_key
req = self.site.simple_request(
action='upload',
Similar blocks of code found in 5 locations. Consider refactoring. Open
ts4 = pywikibot.Timestamp(
year=2023, month=12, day=21, hour=13,
tzinfo=datetime.timezone(datetime.timedelta(hours=-6)))
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 43.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76