wikimedia/pywikibot

View on GitHub

Showing 286 of 616 total issues

Function title has 13 arguments (exceeds 7 allowed). Consider refactoring.
Open

    def title(
Severity: Major
Found in pywikibot/page/_basepage.py - About 1 hr to fix

    Function color_line has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
    Open

        def color_line(self, line: str, line_ref: str | None = None) -> str:
            """Color line characters.
    
            If line_ref is None, the whole line is colored.
            If line_ref[i] is not blank, line[i] is colored.
    Severity: Minor
    Found in pywikibot/diff.py - About 1 hr 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 16 (exceeds 10 allowed). Consider refactoring.
    Open

        def __init__(self, fromurl, **kwargs) -> None:
            """Initializer.
    
            :raises pywikibot.exceptions.ServerError: a server error
                occurred while loading the site
    Severity: Minor
    Found in pywikibot/site_detect.py - About 1 hr 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 _wbset_action has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
    Open

        def _wbset_action(self, itemdef, action: str, action_data,
                          **kwargs) -> dict:
            """Execute wbset{action} on a Wikibase entity.
    
            Supported actions are:
    Severity: Minor
    Found in pywikibot/site/_datasite.py - About 1 hr 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 input_sections has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
    Open

    def input_sections(variant: str,
                       sections: list[_ConfigSection],
                       skip: Callable | None = None,
                       force: bool = False,
                       default: str = 'n') -> list[str]:
    Severity: Minor
    Found in pywikibot/scripts/generate_user_files.py - About 1 hr 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 _fetch has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
    Open

        def _fetch(self, modules: set | frozenset) -> None:
            """Get paraminfo for multiple modules without initializing beforehand.
    
            :param modules: API modules to load and which haven't been loaded yet.
            """
    Severity: Minor
    Found in pywikibot/data/api/_paraminfo.py - About 1 hr 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 stream_output has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
    Open

        def stream_output(self, text, targetStream=None) -> None:
            """Output text to a stream.
    
            If a character can't be displayed in the encoding used by the user's
            terminal, it will be replaced with a question mark or by a
    Severity: Minor
    Found in pywikibot/userinterfaces/terminal_interface_base.py - About 1 hr 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 allpages has 13 arguments (exceeds 7 allowed). Consider refactoring.
    Open

        def allpages(
    Severity: Major
    Found in pywikibot/site/_generators.py - About 1 hr to fix

      Function parse has a Cognitive Complexity of 16 (exceeds 10 allowed). Consider refactoring.
      Open

          def parse(self) -> Iterator[XmlEntry]:
              """Generator using ElementTree iterparse function.
      
              .. versionchanged:: 7.2
                 if a ParseError occurs it can be handled by the callable
      Severity: Minor
      Found in pywikibot/xmlreader.py - About 1 hr 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 36 lines of code (exceeds 30 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/transferbot.py - About 1 hr to fix

        Function __init__ has 12 arguments (exceeds 7 allowed). Consider refactoring.
        Open

            def __init__(self, cat_title: str | None, list_title: str | None,
        Severity: Major
        Found in scripts/category.py - About 1 hr to fix

          Function __init__ has 12 arguments (exceeds 7 allowed). Consider refactoring.
          Open

              def __init__(self,
          Severity: Major
          Found in pywikibot/site/_upload.py - About 1 hr to fix

            Function __init__ has 12 arguments (exceeds 7 allowed). Consider refactoring.
            Open

                def __init__(self,
            Severity: Major
            Found in pywikibot/_wbtypes.py - About 1 hr to fix

              Function categorymembers has 12 arguments (exceeds 7 allowed). Consider refactoring.
              Open

                  def categorymembers(
              Severity: Major
              Found in pywikibot/site/_generators.py - About 1 hr to fix

                Function newpages has 12 arguments (exceeds 7 allowed). Consider refactoring.
                Open

                    def newpages(
                Severity: Major
                Found in pywikibot/site/_generators.py - About 1 hr to fix

                  Function main has a Cognitive Complexity of 15 (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/listpages.py - About 1 hr 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 load_page has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
                  Open

                      def load_page(self) -> None:
                          """Load the page to be archived and break it up into threads.
                  
                          .. versionchanged:: 7.6
                             If `-keep` option is given run through all threads and set
                  Severity: Minor
                  Found in scripts/archivebot.py - About 1 hr 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 15 (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/claimit.py - About 1 hr 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 15 (exceeds 10 allowed). Consider refactoring.
                  Open

                      def __iter__(self):
                          """Iterator method."""
                          try:
                              for entry in self.parser:
                                  if self.skipping:
                  Severity: Minor
                  Found in scripts/replace.py - About 1 hr 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 purgepages has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
                  Open

                      def purgepages(self, flush=False):
                          """Purge a bulk of page if rate limit exceeded.
                  
                          .. versionadded:: 8.0
                          .. versionchanged:: 9.0
                  Severity: Minor
                  Found in scripts/touch.py - About 1 hr 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