wikimedia/pywikibot

View on GitHub

Showing 708 of 708 total issues

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

    def __init__(
Severity: Major
Found in pywikibot/page/_wikibase.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if data['result'] == 'Warning':
                                assert ('warnings' in data
                                        and not ignore_all_warnings)
                                if callable(ignore_warnings):
                                    restart = False
    Severity: Major
    Found in pywikibot/site/_upload.py - About 45 mins to fix

      Function preloadpages has 9 arguments (exceeds 7 allowed). Consider refactoring.
      Open

          def preloadpages(
      Severity: Major
      Found in pywikibot/site/_generators.py - About 45 mins to fix

        Function input has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
        Open

            def input(self, question: str,
                      password: bool = False,
                      default: str | None = '',
                      force: bool = False) -> str:
                """
        Severity: Minor
        Found in pywikibot/userinterfaces/terminal_interface_base.py - About 45 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

        Avoid deeply nested control flow statements.
        Open

                                if hunk.reviewed == Hunk.PENDING:
                                    hunk.reviewed = \
                                        Hunk.APPR if choice == 'a' else Hunk.NOT_APPR
                        position = find_pending(0, position)
        Severity: Major
        Found in pywikibot/diff.py - About 45 mins to fix

          Function get has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
          Open

              def get(self, force: bool = False) -> dict:
                  """
                  Fetch all entity data and cache it.
          
                  :param force: override caching
          Severity: Minor
          Found in pywikibot/page/_wikibase.py - About 45 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

          Avoid deeply nested control flow statements.
          Open

                                  for source in val:
                                      assert source.isReference is True
                                      src_data = source.toJSON()
                                      if 'hash' in src_data:
                                          reference.setdefault('hash', src_data['hash'])
          Severity: Major
          Found in pywikibot/page/_wikibase.py - About 45 mins to fix

            Function topics has 9 arguments (exceeds 7 allowed). Consider refactoring.
            Open

                def topics(self, *,
            Severity: Major
            Found in pywikibot/flow.py - About 45 mins to fix

              Function get has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
              Open

                  def get(self, force: bool = False) -> dict:
                      """Fetch all MediaInfo entity data and cache it.
              
                      .. note:: dicts returned by this method are references to content
                         of this entity and their modifying may indirectly cause
              Severity: Minor
              Found in pywikibot/page/_wikibase.py - About 45 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

              Avoid deeply nested control flow statements.
              Open

                                      if hasattr(obj, '__doc__'):
                                          method.__doc__ = obj.__doc__
                                      return method
              Severity: Major
              Found in pywikibot/site/_basesite.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        for ref_propid, reference in ref_grp['snaks'].items():
                                            for ref_index, ref_stat in enumerate(reference):
                                                target_ref_grp = claim.sources[ref_grp_idx]
                                                target_ref_prop = target_ref_grp[ref_propid]
                                                target_ref = target_ref_prop[ref_index]
                Severity: Major
                Found in pywikibot/page/_wikibase.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if option.handled(answer):
                                              answer = option.result(answer)
                                              output_option(option, before_question=False)
                                              handled = option.stop
                                              break
                  Severity: Major
                  Found in pywikibot/userinterfaces/terminal_interface_base.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if self.sametitle(key, pagedata['title']):
                                                    cache[pagedata['title']] = cache[key]
                                                    break
                                            else:
                    Severity: Major
                    Found in pywikibot/site/_generators.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if family == 'wiki':
                                                  family = 'wikipedia'
                                              return pywikibot.Site(code, family)
                      Severity: Major
                      Found in pywikibot/site/_apisite.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if poll:
                                                    # run a poll; not possible in first iteration
                                                    assert file_key
                                                    req = self.site.simple_request(
                                                        action='upload',
                        Severity: Major
                        Found in pywikibot/site/_upload.py - About 45 mins to fix

                          Function target_equals has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
                          Open

                              def target_equals(self, value) -> bool:
                                  """
                                  Check whether the Claim's target is equal to specified value.
                          
                                  The function checks for:
                          Severity: Minor
                          Found in pywikibot/page/_wikibase.py - About 45 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 edit_elements has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
                          Open

                              def edit_elements(self, data: dict, **kwargs) -> None:
                                  """
                                  Update form elements.
                          
                                  :param data: Data to be saved
                          Severity: Minor
                          Found in pywikibot/page/_wikibase.py - About 45 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 __next__ has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
                          Open

                              def __next__(self) -> pywikibot.page.Page:
                                  """Get next Page."""
                                  while True:
                                      entry = next(self.parser)
                                      if self.skipping:
                          Severity: Minor
                          Found in pywikibot/pagegenerators/_generators.py - About 45 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 login has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
                          Open

                              def login(self, retry: bool = False, autocreate: bool = False) -> bool:
                                  """
                                  Attempt to log into the server.
                          
                                  .. seealso:: :api:`Login`
                          Severity: Minor
                          Found in pywikibot/login.py - About 45 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

                          Avoid deeply nested control flow statements.
                          Open

                                                  if data['result'] == 'Continue':
                                                      throttle = False
                                                      if 'offset' in data:
                                                          new_offset = int(data['offset'])
                                                          if offset + len(chunk) != new_offset:
                          Severity: Major
                          Found in pywikibot/site/_upload.py - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language