wikimedia/pywikibot

View on GitHub

Showing 583 of 583 total issues

File _apisite.py has 2413 lines of code (exceeds 900 allowed). Consider refactoring.
Open

"""Objects representing API interface to MediaWiki site."""
#
# (C) Pywikibot team, 2008-2022
#
# Distributed under the terms of the MIT license.
Severity: Major
Found in pywikibot/site/_apisite.py - About 4 days to fix

    File _page.py has 1954 lines of code (exceeds 900 allowed). Consider refactoring.
    Open

    """Objects representing various types of MediaWiki pages.
    
    This module includes objects:
    
    - BasePage: Base object for a MediaWiki page
    Severity: Major
    Found in pywikibot/page/_page.py - About 3 days to fix

      File bot.py has 1921 lines of code (exceeds 900 allowed). Consider refactoring.
      Open

      """
      User-interface related functions for building bots.
      
      This module supports several different bot classes which could be used in
      conjunction. Each bot should subclass at least one of these four classes:
      Severity: Major
      Found in pywikibot/bot.py - About 3 days to fix

        File site_generators_tests.py has 1906 lines of code (exceeds 900 allowed). Consider refactoring.
        Open

        #!/usr/bin/python3
        """Tests for generators of the site module."""
        #
        # (C) Pywikibot team, 2008-2022
        #
        Severity: Major
        Found in tests/site_generators_tests.py - About 3 days to fix

          File interwiki.py has 1858 lines of code (exceeds 900 allowed). Consider refactoring.
          Open

          #!/usr/bin/python3
          """
          Script to check language links for general pages.
          
          Uses existing translations of a page, plus hints from the command line, to
          Severity: Major
          Found in scripts/interwiki.py - About 3 days to fix

            File _wikibase.py has 1846 lines of code (exceeds 900 allowed). Consider refactoring.
            Open

            """
            Objects representing various types of Wikibase pages and structures.
            
            This module also includes objects:
            
            
            Severity: Major
            Found in pywikibot/page/_wikibase.py - About 3 days to fix

              File wikibase_tests.py has 1808 lines of code (exceeds 900 allowed). Consider refactoring.
              Open

              #!/usr/bin/python3
              """Tests for the Wikidata parts of the page module."""
              #
              # (C) Pywikibot team, 2008-2022
              #
              Severity: Major
              Found in tests/wikibase_tests.py - About 2 days to fix

                File _generators.py has 1783 lines of code (exceeds 900 allowed). Consider refactoring.
                Open

                """Objects representing API generators to MediaWiki site."""
                #
                # (C) Pywikibot team, 2008-2022
                #
                # Distributed under the terms of the MIT license.
                Severity: Major
                Found in pywikibot/site/_generators.py - About 2 days to fix

                  Function _upload has a Cognitive Complexity of 140 (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 2 days 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

                  File date.py has 1675 lines of code (exceeds 900 allowed). Consider refactoring.
                  Open

                  """Date data and manipulation module."""
                  #
                  # (C) Pywikibot team, 2003-2022
                  #
                  # Distributed under the terms of the MIT license.
                  Severity: Major
                  Found in pywikibot/date.py - About 2 days to fix

                    Function treat_disamb_only has a Cognitive Complexity of 130 (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 2 days 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 amend_isbn_edition has a Cognitive Complexity of 126 (exceeds 10 allowed). Consider refactoring.
                    Open

                    def amend_isbn_edition(isbn_number: str):  # noqa: C901
                        """Amend ISBN registration.
                    
                        Amend Wikidata, by registering the ISBN-13 data via P212,
                        depending on the data obtained from the digital library.
                    Severity: Minor
                    Found in scripts/create_isbn_edition.py - About 2 days 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 remove_templates has a Cognitive Complexity of 124 (exceeds 10 allowed). Consider refactoring.
                    Open

                        def remove_templates(self):
                            """Understand if the page is blocked has the right template."""
                    
                            def understand_block():
                                """Understand if the page is blocked has the right template."""
                    Severity: Minor
                    Found in scripts/blockpageschecker.py - About 2 days 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

                    File textlib.py has 1513 lines of code (exceeds 900 allowed). Consider refactoring.
                    Open

                    """
                    Functions for manipulating wiki-text.
                    
                    Unless otherwise noted, all functions take a unicode string as the argument
                    and return a unicode string.
                    Severity: Major
                    Found in pywikibot/textlib.py - About 2 days to fix

                      File pagegenerators_tests.py has 1450 lines of code (exceeds 900 allowed). Consider refactoring.
                      Open

                      #!/usr/bin/python3
                      """Test pagegenerators module."""
                      #
                      # (C) Pywikibot team, 2009-2022
                      #
                      Severity: Major
                      Found in tests/pagegenerators_tests.py - About 1 day to fix

                        File checkimages.py has 1387 lines of code (exceeds 900 allowed). Consider refactoring.
                        Open

                        #!/usr/bin/python3
                        """
                        Script to check recently uploaded files.
                        
                        This script checks if a file description is present and if there are other
                        Severity: Major
                        Found in scripts/checkimages.py - About 1 day to fix

                          APISite has 100 functions (exceeds 30 allowed). Consider refactoring.
                          Open

                          class APISite(
                              BaseSite,
                              EchoMixin,
                              FlowMixin,
                              GeneratorsMixin,
                          Severity: Major
                          Found in pywikibot/site/_apisite.py - About 1 day to fix

                            Function review_hunks has a Cognitive Complexity of 90 (exceeds 10 allowed). Consider refactoring.
                            Open

                                def review_hunks(self) -> None:
                                    """Review hunks."""
                                    def find_pending(start: int, end: int) -> Optional[int]:
                                        step = -1 if start > end else +1
                                        for pending in range(start, end, step):
                            Severity: Minor
                            Found in pywikibot/diff.py - About 1 day 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

                            BasePage has 99 functions (exceeds 30 allowed). Consider refactoring.
                            Open

                            class BasePage(ComparableMixin):
                            
                                """
                                BasePage: Base object for a MediaWiki page.
                            
                            
                            Severity: Major
                            Found in pywikibot/page/_page.py - About 1 day to fix

                              File category.py has 1366 lines of code (exceeds 900 allowed). Consider refactoring.
                              Open

                              #!/usr/bin/python3
                              """Script to manage categories.
                              
                              Syntax:
                              
                              
                              Severity: Major
                              Found in scripts/category.py - About 1 day to fix
                                Severity
                                Category
                                Status
                                Source
                                Language