Showing 616 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
Similar blocks of code found in 4 locations. Consider refactoring. Open
def _handle_titleregex(self, value: str) -> Literal[True]:
"""Handle `-titleregex` argument."""
if not value:
value = pywikibot.input(
'What page names are you looking for?')
- 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 53.
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
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
Similar blocks of code found in 3 locations. Consider refactoring. Open
def test_from_entity_uri_no_item(self):
"""Test ItemPage.from_entity_uri with non-existent item."""
repo = self.get_repo()
entity_uri = 'http://www.wikidata.org/entity/Q999999999999999999'
regex = r"^Page .+ doesn't exist\.$"
- 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 51.
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
Similar blocks of code found in 3 locations. Consider refactoring. Open
def test_from_entity_uri_invalid_title(self):
"""Test ItemPage.from_entity_uri with an invalid item title format."""
repo = self.get_repo()
entity_uri = 'http://www.wikidata.org/entity/Nonsense'
regex = r"^'.+' is not a valid .+ page title$"
- 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 51.
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
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
Similar blocks of code found in 3 locations. Consider refactoring. Open
def test_from_entity_uri_wrong_repo(self):
"""Test ItemPage.from_entity_uri with unexpected item repo."""
repo = self.get_repo()
entity_uri = 'http://test.wikidata.org/entity/Q124'
regex = (r'^The supplied data repository \(.+\) does not '
- 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 51.
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
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"