wikimedia/pywikibot

View on GitHub

Showing 286 of 616 total issues

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

    def treat_disamb_only(self, ref_page, disamb_page) -> str:
        """Resolve the links to disamb_page but don't look for its redirects.

        :param disamb_page: the disambiguation page or redirect we don't want
            anything to link to
Severity: Minor
Found in scripts/solve_disambiguation.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 addReferences has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def addReferences(self, oldText) -> str:
        """Add a references tag into an existing section where it fits into.

        If there is no such section, creates a new section containing
        the references tag. Also repair malformed references tags.
Severity: Minor
Found in scripts/noreferences.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 __iter__ has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def __iter__(self) -> Generator[pywikibot.Page]:
        """Yield pages."""
        # TODO: start yielding before all referring pages have been found
        refs = list(self.page.getReferences(with_template_inclusion=False,
                                            namespaces=0 if self.main_only
Severity: Minor
Found in scripts/solve_disambiguation.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 run has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def run(self) -> None:
        """Main function of CategoryGraphBot."""
        self.scan_level(self.cat, int(self.args.depth))
        # reduce too big graph
        if self.counter > 1000:
Severity: Minor
Found in scripts/category_graph.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 lacksReferences has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def lacksReferences(self, text) -> bool:
        """Check whether or not the page is lacking a references tag."""
        oldTextCleaned = textlib.removeDisabledParts(text)
        if self.referencesR.search(oldTextCleaned) \
           or self.referencesTagR.search(oldTextCleaned):
Severity: Minor
Found in scripts/noreferences.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 test_watchlist_revs has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def test_watchlist_revs(self):
        """Test the site.watchlist_revs() method."""
        mysite = self.get_site()
        wl = list(mysite.watchlist_revs(total=10))
        self.assertLessEqual(len(wl), 10)
Severity: Minor
Found in tests/site_generators_tests.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 daemonize has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

def daemonize(close_fd: bool = True,
              chdir: bool = True,
              redirect_std: str | None = None) -> None:
    """Daemonize the current process.

Severity: Minor
Found in pywikibot/daemonize.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 handle has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def handle(self) -> Any:
        """Handle by either applying the new section or label."""
        if not self.replacer:
            raise ValueError('LinkChoice requires a replacer')

Severity: Minor
Found in pywikibot/bot_choice.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 create_diff has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def create_diff(self) -> Iterable[str]:
        """Generator of diff text for this hunk, without formatting.

        Check each line ends with line feed to prevent behaviour like
        :issue:`46395`
Severity: Minor
Found in pywikibot/diff.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 _upload has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def _upload(self, ignore_warnings, report_success,
                file_key=None, offset=0) -> bool:
        """Recursive Upload method.

        :param file_key: Reuses an already uploaded file using the
Severity: Minor
Found in pywikibot/site/_upload.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 translateMagicWords has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

    def translateMagicWords(self, text: str) -> str:
        """Use localized magic words."""
        # not wanted at ru
        # arz uses English stylish codes
        # no need to run on English wikis
Severity: Minor
Found in pywikibot/cosmetic_changes.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 blockuser has 10 arguments (exceeds 7 allowed). Consider refactoring.
Open

    def blockuser(
Severity: Major
Found in pywikibot/site/_apisite.py - About 50 mins to fix

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

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

      Function usercontribs has 10 arguments (exceeds 7 allowed). Consider refactoring.
      Open

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

        Function logevents has 10 arguments (exceeds 7 allowed). Consider refactoring.
        Open

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

          Function allimages has 10 arguments (exceeds 7 allowed). Consider refactoring.
          Open

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

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

                def treat(self, page):
                    """Treat a single page."""
                    if not page.exists():
                        pywikibot.info('*** The sandbox is not existent, skipping.')
                        return
            Severity: Minor
            Found in scripts/clean_sandbox.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

                                    while result <= maxlen:
                                        result += 1
                                        final = redirects[final]
            
                            # only yield multiple or broken redirects
            Severity: Major
            Found in scripts/redirect.py - About 45 mins to fix

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

                  def determine_type_target(
                      self,
                      page: pywikibot.Page
                  ) -> pywikibot.Page | None:
                      """Return page to be categorized by type.
              Severity: Minor
              Found in scripts/category.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 __new__ has a Cognitive Complexity of 13 (exceeds 10 allowed). Consider refactoring.
              Open

                  def __new__(cls, name, bases, dct):
                      """Create the new class."""
                      def test_method(formatname):
              
                          def testMapEntry(self):
              Severity: Minor
              Found in tests/date_tests.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

              Severity
              Category
              Status
              Source
              Language