wikimedia/pywikibot

View on GitHub

Showing 286 of 616 total issues

Avoid too many return statements within this function.
Open

        return False
Severity: Major
Found in pywikibot/pagegenerators/_factory.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return False
    Severity: Major
    Found in pywikibot/site/_namespace.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return any(function(data) for function in self.filter['any'])
      Severity: Major
      Found in pywikibot/comms/eventstreams.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                    return True
        Severity: Major
        Found in pywikibot/pagegenerators/_factory.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return True
          Severity: Major
          Found in pywikibot/tools/djvu.py - About 30 mins to fix

            Function skip_page has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def skip_page(self, page):
                    """Skip if -exceptUrl matches or page does not exists."""
                    if page.exists():
                        if self.opt.createonly:
                            pywikibot.warning(f'Skipping because {page} already exists')
            Severity: Minor
            Found in scripts/add_text.py - About 25 mins to fix

            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 11 (exceeds 10 allowed). Consider refactoring.
            Open

            def main() -> None:
                """Print environment variables."""
                _pwb_dir = os.path.abspath(os.path.join(
                    os.path.split(__file__)[0], '..', '..'))
                _pwb_dir = first_upper(_pwb_dir)
            Severity: Minor
            Found in tests/pwb/print_env.py - About 25 mins to fix

            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 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def run(self) -> None:
                    """Run bot."""
                    self.site.login()
                    while True:
                        self.wait = False
            Severity: Minor
            Found in scripts/clean_sandbox.py - About 25 mins to fix

            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 11 (exceeds 10 allowed). Consider refactoring.
            Open

            def main(*args: str) -> None:
                """Process command line arguments and invoke ParserFunctionCountBot."""
                local_args = pywikibot.handle_args(*args)
                options = {}
            
            
            Severity: Minor
            Found in scripts/parser_function_count.py - About 25 mins to fix

            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 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def __init__(self, **kwargs) -> None:
                    """Initializer."""
                    super().__init__(**kwargs)
                    self._use_fake_user_agent = config.fake_user_agent_default.get(
                        'reflinks', False)
            Severity: Minor
            Found in scripts/reflinks.py - About 25 mins to fix

            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 test_search has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def test_search(self):
                    """Test the site.search() method."""
                    mysite = self.site
                    try:
                        se = list(mysite.search('wiki', total=100, namespaces=0))
            Severity: Minor
            Found in tests/site_generators_tests.py - About 25 mins to fix

            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 __iter__ has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def __iter__(self):
                    """Iterator."""
                    n = 0
                    while self._total is None or n < self._total:
                        if not hasattr(self, 'source'):
            Severity: Minor
            Found in tests/eventstreams_tests.py - About 25 mins to fix

            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 _test_dedup_int has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def _test_dedup_int(self, deduped, deduper, key=None):
                    """Test filter_unique results for int."""
                    if not key:
                        key = passthrough
            
            
            Severity: Minor
            Found in tests/tools_tests.py - About 25 mins to fix

            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 11 (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.
            
            
            Severity: Minor
            Found in scripts/cosmetic_changes.py - About 25 mins to fix

            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 test_getattr has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def test_getattr(self):
                    """Test NamespacesDict.__getattr__."""
                    for ns_id, values in self.tests.items():
                        for name in values:
                            if name.endswith(':') or ' ' in name:
            Severity: Minor
            Found in tests/namespace_tests.py - About 25 mins to fix

            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 test_logevents has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def test_logevents(self):
                    """Test logevents method."""
                    mysite = self.get_site()
                    le = list(mysite.logevents(total=10))
                    self.assertLessEqual(len(le), 10)
            Severity: Minor
            Found in tests/site_generators_tests.py - About 25 mins to fix

            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 11 (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.
            
            
            Severity: Minor
            Found in scripts/category_redirect.py - About 25 mins to fix

            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 test_pages_with_property has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def test_pages_with_property(self):
                    """Test pages_with_property method."""
                    mysite = self.get_site()
                    pnames = mysite.get_property_names()
                    for item in ('defaultsort', 'disambiguation', 'displaytitle',
            Severity: Minor
            Found in tests/site_generators_tests.py - About 25 mins to fix

            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 test_pages_with_property_generator has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def test_pages_with_property_generator(self):
                    """Test the pages_with_property_generator method."""
                    mysite = self.get_site()
                    for item in ('defaultsort', 'disambiguation', 'displaytitle',
                                 'hiddencat', 'invalid_property'):
            Severity: Minor
            Found in tests/pagegenerators_tests.py - About 25 mins to fix

            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_cr_templates has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
            Open

                def _get_cr_templates(self, code, fallback) -> None:
                    """Build list of category redirect templates."""
                    if not hasattr(self, '_catredirtemplates'):
                        self._catredirtemplates = {}
                    if code in self.category_redirect_templates:
            Severity: Minor
            Found in pywikibot/family.py - About 25 mins to fix

            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

            Severity
            Category
            Status
            Source
            Language