wikimedia/pywikibot

View on GitHub

Showing 286 of 616 total issues

Function _get_siteinfo has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
Open

    def _get_siteinfo(self, prop, expiry) -> dict:
        """Retrieve a siteinfo property.

        All properties which the site doesn't
        support contain the default value. Because pre-1.12 no data was
Severity: Minor
Found in pywikibot/site/_siteinfo.py - About 2 hrs 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 deprecated has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
Open

def deprecated(*args, **kwargs):
    """Decorator to output a deprecation warning.

    .. versionchanged:: 7.0
       `since` keyword must be a release number, not a timestamp.
Severity: Minor
Found in pywikibot/tools/_deprecate.py - About 2 hrs 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_page_info has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
Open

    def _get_page_info(self, force: bool = False):
        """Return a dict of tuples for all pages of djvu file.

        The tuples consist of (id, (size, dpi)).
        :param force: if True, refresh the cached data
Severity: Minor
Found in pywikibot/tools/djvu.py - About 2 hrs 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

File _wbtypes.py has 931 lines of code (exceeds 900 allowed). Consider refactoring.
Open

"""Wikibase data type classes."""
#
# (C) Pywikibot team, 2013-2024
#
# Distributed under the terms of the MIT license.
Severity: Major
Found in pywikibot/_wbtypes.py - About 2 hrs to fix

    Function format has a Cognitive Complexity of 24 (exceeds 10 allowed). Consider refactoring.
    Open

        def format(self, default: str | None = None) -> str:
            """Return a formatted string showing the range."""
            value: int | None = None
    
            if default is not None and self.test(default):
    Severity: Minor
    Found in pywikibot/bot_choice.py - About 2 hrs 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 cleanUpLinks has a Cognitive Complexity of 24 (exceeds 10 allowed). Consider refactoring.
    Open

        def cleanUpLinks(self, text: str) -> str:
            """Tidy up wikilinks found in a string.
    
            This function will:
    
    
    Severity: Minor
    Found in pywikibot/cosmetic_changes.py - About 2 hrs 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

    TestSiteGenerators has 33 functions (exceeds 30 allowed). Consider refactoring.
    Open

    class TestSiteGenerators(DefaultSiteTestCase):
    
        """Test cases for Site methods."""
    
        cached = True
    Severity: Minor
    Found in tests/site_generators_tests.py - About 2 hrs to fix

      Function bad_name_filer has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
      Open

          def bad_name_filer(self, name, force: bool = False) -> bool:
              """Check for bad names."""
              if not globalvar.filt_bad_name:
                  return False
      
      
      Severity: Minor
      Found in scripts/welcome.py - About 2 hrs 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 templatesWithParams has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
      Open

          def templatesWithParams(  # noqa: N802
              self,
          ) -> list[tuple[pywikibot.Page, list[str]]]:
              """Return templates used on this Page.
      
      
      Severity: Minor
      Found in pywikibot/page/_page.py - About 2 hrs 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 members has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
      Open

          def members(self, *,
                      recurse: bool = False,
                      total: int | None = None,
                      **kwargs: Any) -> Generator[Page, None, None]:
              """Yield all category contents (subcats, pages, and files).
      Severity: Minor
      Found in pywikibot/page/_category.py - About 2 hrs 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 23 (exceeds 10 allowed). Consider refactoring.
      Open

          def __init__(self,
                       year: int | None = None,
                       month: int | None = None,
                       day: int | None = None,
                       hour: int | None = None,
      Severity: Minor
      Found in pywikibot/_wbtypes.py - About 2 hrs 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 authorship has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
      Open

          def authorship(
              self,
              n: int | None = None,
              *,
              min_chars: int = 0,
      Severity: Minor
      Found in pywikibot/page/_toolforge.py - About 2 hrs 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 find_all has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
      Open

          def find_all(self, s):
              """Highlight all occurrences of string s, and select the first one.
      
              If the string has already been highlighted, jump to the next occurrence
              after the current selection. (You cannot go backwards using the
      Severity: Minor
      Found in pywikibot/userinterfaces/gui.py - About 2 hrs 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 Site has a Cognitive Complexity of 23 (exceeds 10 allowed). Consider refactoring.
      Open

      def Site(code: str | None = None,  # noqa: N802
               fam: str | Family | None = None,
               user: str | None = None, *,
               interface: str | _BaseSite | None = None,
               url: str | None = None) -> _BaseSite:
      Severity: Minor
      Found in pywikibot/__init__.py - About 2 hrs 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_site_and_lang has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
      Open

      def get_site_and_lang(
          default_family: str | None = 'wikipedia',
          default_lang: str | None = 'en',
          default_username: str | None = None,
          force: bool = False
      Severity: Minor
      Found in pywikibot/scripts/generate_user_files.py - About 2 hrs 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 standardizePageFooter has a Cognitive Complexity of 22 (exceeds 10 allowed). Consider refactoring.
      Open

          def standardizePageFooter(self, text: str) -> str:
              """Standardize page footer.
      
              Makes sure that interwiki links and categories are put into the
              correct position and into the right order.
      Severity: Minor
      Found in pywikibot/cosmetic_changes.py - About 2 hrs 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_blocks has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
      Open

          def test_blocks(self):
              """Test the site.blocks() method."""
              mysite = self.get_site()
              props = ('id', 'by', 'timestamp', 'expiry', 'reason')
      
      
      Severity: Minor
      Found in tests/site_generators_tests.py - About 2 hrs 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 treat_page has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
      Open

          def treat_page(self) -> None:
              """Upload page content."""
              page = self.current_page
              title = page.title()
              # save the content retrieved from generator
      Severity: Minor
      Found in scripts/pagefromfile.py - About 2 hrs 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 filter_unique has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
      Open

      def filter_unique(iterable, container=None, key=None, add=None):
          """Yield unique items from an iterable, omitting duplicates.
      
          By default, to provide uniqueness, it puts the generated items into a
          set created as a local variable. It only yields items which are not
      Severity: Minor
      Found in pywikibot/tools/itertools.py - About 2 hrs 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_handlers has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
      Open

      def init_handlers() -> None:
          """Initialize the handlers and formatters for the logging system.
      
          This relies on the global variable :attr:`ui` which is a UI object.
      
      
      Severity: Minor
      Found in pywikibot/bot.py - About 2 hrs 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