wikimedia/pywikibot

View on GitHub

Showing 286 of 616 total issues

Function query has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def query(self, query: str, headers: dict[str, str] | None = None):
        """Run SPARQL query and return parsed JSON result.

        .. versionchanged:: 8.5
           :exc:`exceptions.NoUsernameError` is raised if the response
Severity: Minor
Found in pywikibot/data/sparql.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 parsevalue has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def parsevalue(self, datatype: str, values: list[str],
                   options: dict[str, Any] | None = None,
                   language: str | None = None,
                   validate: bool = False) -> list[Any]:
        """Send data values to the wikibase parser for interpretation.
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 change_base_dir has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

def change_base_dir():
    """Create a new user directory."""
    while True:
        new_base = pywikibot.input('New user directory? ')
        new_base = os.path.abspath(new_base)
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 select has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def select(self,
               query: str,
               full_data: bool = False,
               headers: dict[str, str] | None = None
               ) -> list[dict[str, str]] | None:
Severity: Minor
Found in pywikibot/data/sparql.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 normalize has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def normalize(self) -> WbTime:
        """Normalizes the WbTime object to account for precision.

        Normalization is needed because WbTime objects can have hidden
        values that affect naive comparisons, such as an object set to
Severity: Minor
Found in pywikibot/_wbtypes.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 _detect_win32_editor has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def _detect_win32_editor() -> str:
        """Detect the best Win32 editor."""
        # Notepad is even worse than our Tkinter editor.
        unusable_exes = ['notepad.exe',
                         'py.exe',
Severity: Minor
Found in pywikibot/editor.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 pagelanglinks has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def pagelanglinks(
        self,
        page: pywikibot.Page,
        *,
        total: int | None = None,
Severity: Minor
Found in pywikibot/site/_generators.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 editEntity has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
Open

    def editEntity(self,
                   entity: pywikibot.page.WikibaseEntity | dict,
                   data: dict,
                   bot: bool = True,
                   **kwargs) -> dict:
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 test_RegexFilterPageGenerator has 32 lines of code (exceeds 30 allowed). Consider refactoring.
Open

    def test_RegexFilterPageGenerator(self):
        """Test RegexFilterPageGenerator."""
        self.assertFunction('RegexFilterPageGenerator')
        gen = pagegenerators.PagesFromTitlesGenerator(self.titles, self.site)
        gen = pagegenerators.RegexFilterPageGenerator(gen, '/doc')
Severity: Minor
Found in tests/pagegenerators_tests.py - About 1 hr to fix

    Consider simplifying this complex logical expression.
    Open

                    if (removing and not self.conf.autonomous
                        or modifying and self.problemfound
                        or not old
                        or (self.conf.needlimit
                            and len(adding) + len(modifying)
    Severity: Major
    Found in scripts/interwiki.py - About 1 hr to fix

      Function put has 11 arguments (exceeds 7 allowed). Consider refactoring.
      Open

          def put(self, newtext: str,
      Severity: Major
      Found in pywikibot/page/_basepage.py - About 1 hr to fix

        Function save has 11 arguments (exceeds 7 allowed). Consider refactoring.
        Open

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

          Consider simplifying this complex logical expression.
          Open

                          if replaceit and trailing_chars:
                              newlink = f'[[{new_page_title}{section}]]{trailing_chars}'
                          elif replaceit or (new_page_title == link_text
                                             and not section):
                              newlink = f'[[{new_page_title}]]'
          Severity: Major
          Found in scripts/solve_disambiguation.py - About 1 hr to fix

            Consider simplifying this complex logical expression.
            Open

                        if force_interwiki \
                           or (allow_interwiki
                               and (self.site.family.name != target_family
                                    or self.site.code != target_code)):
                            if self.site.family.name not in (
            Severity: Major
            Found in pywikibot/page/_basepage.py - About 1 hr to fix

              Function editpage has 11 arguments (exceeds 7 allowed). Consider refactoring.
              Open

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

                Function load_topiclist has 11 arguments (exceeds 7 allowed). Consider refactoring.
                Open

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

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

                      def __init__(self, lat: float, lon: float, alt: float | None = None,
                  Severity: Major
                  Found in pywikibot/_wbtypes.py - About 1 hr to fix

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

                    def parse(argv: Sequence[str],
                              generator_factory: pagegenerators.GeneratorFactory
                              ) -> dict[str, bool | str]:
                        """Parses our arguments and provide a dictionary with their values.
                    
                    
                    Severity: Minor
                    Found in scripts/add_text.py - About 55 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 treat_page has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
                    Open

                        def treat_page(self) -> None:
                            """Process one page from the generator."""
                            if self.opt.undelete:
                                self.current_page.undelete(self.summary)
                                self.counter['undelete'] += 1
                    Severity: Minor
                    Found in scripts/delete.py - About 55 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_dump_name has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
                    Open

                        def get_dump_name(db_name, typ, dumpdate):
                            """Check if dump file exists locally in a Toolforge server."""
                            db_path = f'/public/dumps/public/{db_name}/'
                            if os.path.isdir(db_path):
                                dump_filepath_template = (
                    Severity: Minor
                    Found in scripts/download_dump.py - About 55 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