wikimedia/pywikibot

View on GitHub

Showing 616 of 616 total issues

Function categorymembers has 12 arguments (exceeds 7 allowed). Consider refactoring.
Open

    def categorymembers(
Severity: Major
Found in pywikibot/site/_generators.py - About 1 hr to fix

    Function newpages has 12 arguments (exceeds 7 allowed). Consider refactoring.
    Open

        def newpages(
    Severity: Major
    Found in pywikibot/site/_generators.py - About 1 hr to fix

      Function main has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

      def main(*args: str) -> None:
          """Process command line arguments and invoke bot.
      
          If args is an empty list, sys.argv is used.
      
      
      Severity: Minor
      Found in scripts/listpages.py - About 1 hr 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 load_page has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def load_page(self) -> None:
              """Load the page to be archived and break it up into threads.
      
              .. versionchanged:: 7.6
                 If `-keep` option is given run through all threads and set
      Severity: Minor
      Found in scripts/archivebot.py - About 1 hr 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 main has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

      def main(*args: str) -> None:
          """Process command line arguments and invoke bot.
      
          If args is an empty list, sys.argv is used.
      
      
      Severity: Minor
      Found in scripts/claimit.py - About 1 hr 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 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def __iter__(self):
              """Iterator method."""
              try:
                  for entry in self.parser:
                      if self.skipping:
      Severity: Minor
      Found in scripts/replace.py - About 1 hr 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 purgepages has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def purgepages(self, flush=False):
              """Purge a bulk of page if rate limit exceeded.
      
              .. versionadded:: 8.0
              .. versionchanged:: 9.0
      Severity: Minor
      Found in scripts/touch.py - About 1 hr 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 query has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def query(self, query: str, headers: dict[str, str] | None = None):
              """Run SPARQL query and return parsed JSON result.
      
              .. versionchanged:: 8.5
                 :exc:`exceptions.NoUsernameError` is raised if the response
      Severity: Minor
      Found in pywikibot/data/sparql.py - About 1 hr 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

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

          def test_critical(self):
              pywikibot.critical('critical')
              self.assertEqual(self.strout.getvalue(), '')
              self.assertEqual(self.strerr.getvalue(), 'CRITICAL: critical\n')
      Severity: Major
      Found in tests/ui_tests.py and 6 other locations - About 1 hr to fix
      tests/ui_tests.py on lines 122..125
      tests/ui_tests.py on lines 127..130
      tests/ui_tests.py on lines 132..135
      tests/ui_tests.py on lines 137..140
      tests/ui_tests.py on lines 142..145
      tests/ui_tests.py on lines 318..321

      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 47.

      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 7 locations. Consider refactoring.
      Open

          def test_output(self):
              pywikibot.info('output')
              self.assertEqual(self.strout.getvalue(), '')
              self.assertEqual(self.strerr.getvalue(), 'output\n')
      Severity: Major
      Found in tests/ui_tests.py and 6 other locations - About 1 hr to fix
      tests/ui_tests.py on lines 127..130
      tests/ui_tests.py on lines 132..135
      tests/ui_tests.py on lines 137..140
      tests/ui_tests.py on lines 142..145
      tests/ui_tests.py on lines 147..150
      tests/ui_tests.py on lines 318..321

      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 47.

      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 7 locations. Consider refactoring.
      Open

          def test_error(self):
              pywikibot.error('error')
              self.assertEqual(self.strout.getvalue(), '')
              self.assertEqual(self.strerr.getvalue(), 'ERROR: error\n')
      Severity: Major
      Found in tests/ui_tests.py and 6 other locations - About 1 hr to fix
      tests/ui_tests.py on lines 122..125
      tests/ui_tests.py on lines 127..130
      tests/ui_tests.py on lines 132..135
      tests/ui_tests.py on lines 142..145
      tests/ui_tests.py on lines 147..150
      tests/ui_tests.py on lines 318..321

      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 47.

      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

      Function parsevalue has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def parsevalue(self, datatype: str, values: list[str],
                         options: dict[str, Any] | None = None,
                         language: str | None = None,
                         validate: bool = False) -> list[Any]:
              """Send data values to the wikibase parser for interpretation.
      Severity: Minor
      Found in pywikibot/site/_datasite.py - About 1 hr 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

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

          def test_warning(self):
              pywikibot.warning('warning')
              self.assertEqual(self.strout.getvalue(), '')
              self.assertEqual(self.strerr.getvalue(), 'WARNING: warning\n')
      Severity: Major
      Found in tests/ui_tests.py and 6 other locations - About 1 hr to fix
      tests/ui_tests.py on lines 122..125
      tests/ui_tests.py on lines 127..130
      tests/ui_tests.py on lines 137..140
      tests/ui_tests.py on lines 142..145
      tests/ui_tests.py on lines 147..150
      tests/ui_tests.py on lines 318..321

      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 47.

      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

      Function change_base_dir has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

      def change_base_dir():
          """Create a new user directory."""
          while True:
              new_base = pywikibot.input('New user directory? ')
              new_base = os.path.abspath(new_base)
      Severity: Minor
      Found in pywikibot/scripts/generate_user_files.py - About 1 hr 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 select has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def select(self,
                     query: str,
                     full_data: bool = False,
                     headers: dict[str, str] | None = None
                     ) -> list[dict[str, str]] | None:
      Severity: Minor
      Found in pywikibot/data/sparql.py - About 1 hr 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

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

          def test_log(self):
              pywikibot.log('log')
              self.assertEqual(self.strout.getvalue(), '')
              self.assertEqual(self.strerr.getvalue(), '')
      Severity: Major
      Found in tests/ui_tests.py and 6 other locations - About 1 hr to fix
      tests/ui_tests.py on lines 122..125
      tests/ui_tests.py on lines 127..130
      tests/ui_tests.py on lines 132..135
      tests/ui_tests.py on lines 137..140
      tests/ui_tests.py on lines 147..150
      tests/ui_tests.py on lines 318..321

      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 47.

      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 7 locations. Consider refactoring.
      Open

          def testOutputUnicodeText(self):
              pywikibot.info('Заглавная_страница')
              self.assertEqual(self.strout.getvalue(), '')
              self.assertEqual(self.strerr.getvalue(), 'Заглавная_страница\n')
      Severity: Major
      Found in tests/ui_tests.py and 6 other locations - About 1 hr to fix
      tests/ui_tests.py on lines 122..125
      tests/ui_tests.py on lines 127..130
      tests/ui_tests.py on lines 132..135
      tests/ui_tests.py on lines 137..140
      tests/ui_tests.py on lines 142..145
      tests/ui_tests.py on lines 147..150

      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 47.

      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

      Function normalize has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def normalize(self) -> WbTime:
              """Normalizes the WbTime object to account for precision.
      
              Normalization is needed because WbTime objects can have hidden
              values that affect naive comparisons, such as an object set to
      Severity: Minor
      Found in pywikibot/_wbtypes.py - About 1 hr 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 _detect_win32_editor has a Cognitive Complexity of 15 (exceeds 10 allowed). Consider refactoring.
      Open

          def _detect_win32_editor() -> str:
              """Detect the best Win32 editor."""
              # Notepad is even worse than our Tkinter editor.
              unusable_exes = ['notepad.exe',
                               'py.exe',
      Severity: Minor
      Found in pywikibot/editor.py - About 1 hr 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

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

          def test_stdout(self):
              pywikibot.stdout('output')
              self.assertEqual(self.strout.getvalue(), 'output\n')
              self.assertEqual(self.strerr.getvalue(), '')
      Severity: Major
      Found in tests/ui_tests.py and 6 other locations - About 1 hr to fix
      tests/ui_tests.py on lines 122..125
      tests/ui_tests.py on lines 132..135
      tests/ui_tests.py on lines 137..140
      tests/ui_tests.py on lines 142..145
      tests/ui_tests.py on lines 147..150
      tests/ui_tests.py on lines 318..321

      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 47.

      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