wikimedia/pywikibot

View on GitHub
tests/site_generators_tests.py

Summary

Maintainability
F
4 days
Test Coverage

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

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

    TestSiteGenerators has 34 functions (exceeds 30 allowed). Consider refactoring.
    Open

    class TestSiteGenerators(DefaultSiteTestCase):
        """Test cases for Site methods."""
    
        cached = True
    
    
    Severity: Minor
    Found in tests/site_generators_tests.py - About 2 hrs to fix

      Function test_blocks has a Cognitive Complexity of 21 (exceeds 10 allowed). Consider refactoring.
      Open

          def test_blocks(self):
              """Test the site.blocks() method."""
              mysite = self.get_site()
              props = ('id', 'by', 'timestamp', 'expiry', 'reason')
      
      
      Severity: Minor
      Found in tests/site_generators_tests.py - About 2 hrs 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 test_search has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

          def test_search(self):
              """Test the site.search() method."""
              mysite = self.site
              try:
                  se = list(mysite.search('wiki', total=100, namespaces=0))
      Severity: Minor
      Found in tests/site_generators_tests.py - About 25 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_pages_with_property has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

          def test_pages_with_property(self):
              """Test pages_with_property method."""
              mysite = self.get_site()
              pnames = mysite.get_property_names()
              for item in ('defaultsort', 'disambiguation', 'displaytitle',
      Severity: Minor
      Found in tests/site_generators_tests.py - About 25 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_logevents has a Cognitive Complexity of 11 (exceeds 10 allowed). Consider refactoring.
      Open

          def test_logevents(self):
              """Test logevents method."""
              mysite = self.get_site()
              le = list(mysite.logevents(total=10))
              self.assertLessEqual(len(le), 10)
      Severity: Minor
      Found in tests/site_generators_tests.py - About 25 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

      TODO found
      Open

              # TODO test other optional arguments
      Severity: Minor
      Found in tests/site_generators_tests.py by fixme

      There are no issues that match your filters.

      Category
      Status