wikimedia/pywikibot

View on GitHub

Showing 708 of 708 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
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 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

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 check_modules has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

def check_modules(script: str | None = None) -> bool:
    """Check whether mandatory modules are present.

    This also checks Python version when importing dependencies from setup.py

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

def handle_args(
    _,
    *args: str,
) -> tuple[str, list[str], list[str], list[str]]:
    """Handle args and get filename.
Severity: Minor
Found in pywikibot/scripts/wrapper.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 _flush has a Cognitive Complexity of 14 (exceeds 10 allowed). Consider refactoring.
Open

def _flush(stop: bool = True) -> None:
    """Drop this process from the throttle log, after pending threads finish.

    Wait for the page-putter to flush its queue. Also drop this process
    from the throttle log. Called automatically at Python exit.
Severity: Minor
Found in pywikibot/__init__.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 load_topiclist has 10 arguments (exceeds 7 allowed). Consider refactoring.
    Open

        def load_topiclist(self,
    Severity: Major
    Found in pywikibot/site/_extensions.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 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 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

            Similar blocks of code found in 9 locations. Consider refactoring.
            Open

                def hide(self, reason: str) -> None:
                    """Hide this topic.
            
                    :param reason: The reason for hiding this topic.
                    """
            Severity: Major
            Found in pywikibot/flow.py and 8 other locations - About 50 mins to fix
            pywikibot/flow.py on lines 343..350
            pywikibot/flow.py on lines 361..368
            pywikibot/flow.py on lines 370..377
            pywikibot/flow.py on lines 389..396
            pywikibot/flow.py on lines 586..593
            pywikibot/flow.py on lines 595..602
            pywikibot/flow.py on lines 604..611
            pywikibot/flow.py on lines 613..620

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 44.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 9 locations. Consider refactoring.
            Open

                def summarize(self, summary: str) -> None:
                    """Summarize this topic.
            
                    :param summary: The summary that will be added to the topic.
                    """
            Severity: Major
            Found in pywikibot/flow.py and 8 other locations - About 50 mins to fix
            pywikibot/flow.py on lines 343..350
            pywikibot/flow.py on lines 352..359
            pywikibot/flow.py on lines 361..368
            pywikibot/flow.py on lines 370..377
            pywikibot/flow.py on lines 586..593
            pywikibot/flow.py on lines 595..602
            pywikibot/flow.py on lines 604..611
            pywikibot/flow.py on lines 613..620

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 44.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 9 locations. Consider refactoring.
            Open

                def suppress(self, reason: str) -> None:
                    """Suppress this post.
            
                    :param reason: The reason for suppressing this post.
                    """
            Severity: Major
            Found in pywikibot/flow.py and 8 other locations - About 50 mins to fix
            pywikibot/flow.py on lines 343..350
            pywikibot/flow.py on lines 352..359
            pywikibot/flow.py on lines 361..368
            pywikibot/flow.py on lines 370..377
            pywikibot/flow.py on lines 389..396
            pywikibot/flow.py on lines 586..593
            pywikibot/flow.py on lines 595..602
            pywikibot/flow.py on lines 613..620

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 44.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 6 locations. Consider refactoring.
            Open

                    t3 = pywikibot.WbTime(site=repo, year=2010, month=1, day=1, hour=12,
                                          minute=43, second=12,
                                          precision=pywikibot.WbTime.PRECISION['minute'])
            Severity: Major
            Found in tests/wikibase_tests.py and 5 other locations - About 50 mins to fix
            tests/wikibase_tests.py on lines 359..361
            tests/wikibase_tests.py on lines 365..367
            tests/wikibase_tests.py on lines 368..370
            tests/wikibase_tests.py on lines 371..373
            tests/wikibase_tests.py on lines 374..376

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 44.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 9 locations. Consider refactoring.
            Open

                def hide(self, reason: str) -> None:
                    """Hide this post.
            
                    :param reason: The reason for hiding this post.
                    """
            Severity: Major
            Found in pywikibot/flow.py and 8 other locations - About 50 mins to fix
            pywikibot/flow.py on lines 343..350
            pywikibot/flow.py on lines 352..359
            pywikibot/flow.py on lines 361..368
            pywikibot/flow.py on lines 370..377
            pywikibot/flow.py on lines 389..396
            pywikibot/flow.py on lines 586..593
            pywikibot/flow.py on lines 604..611
            pywikibot/flow.py on lines 613..620

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 44.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Similar blocks of code found in 9 locations. Consider refactoring.
            Open

                def suppress(self, reason: str) -> None:
                    """Suppress this topic.
            
                    :param reason: The reason for suppressing this topic.
                    """
            Severity: Major
            Found in pywikibot/flow.py and 8 other locations - About 50 mins to fix
            pywikibot/flow.py on lines 343..350
            pywikibot/flow.py on lines 352..359
            pywikibot/flow.py on lines 370..377
            pywikibot/flow.py on lines 389..396
            pywikibot/flow.py on lines 586..593
            pywikibot/flow.py on lines 595..602
            pywikibot/flow.py on lines 604..611
            pywikibot/flow.py on lines 613..620

            Duplicated Code

            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

            Tuning

            This issue has a mass of 44.

            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

            Refactorings

            Further Reading

            Severity
            Category
            Status
            Source
            Language