wikimedia/pywikibot

View on GitHub
pywikibot/page/_links.py

Summary

Maintainability
C
1 day
Test Coverage

Function parse has a Cognitive Complexity of 46 (exceeds 10 allowed). Consider refactoring.
Open

    def parse(self):
        """
        Parse wikitext of the link.

        Called internally when accessing attributes.
Severity: Minor
Found in pywikibot/page/_links.py - About 6 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

Consider simplifying this complex logical expression.
Open

        if '.' in t and (t in ('.', '..')
                         or t.startswith(('./', '../'))
                         or '/./' in t
                         or '/../' in t
                         or t.endswith(('/.', '/..'))):
Severity: Major
Found in pywikibot/page/_links.py - About 40 mins to fix

    Function parse_site has a Cognitive Complexity of 12 (exceeds 10 allowed). Consider refactoring.
    Open

        def parse_site(self) -> tuple:
            """
            Parse only enough text to determine which site the link points to.
    
            This method does not parse anything after the first ":"; links
    Severity: Minor
    Found in pywikibot/page/_links.py - About 35 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 too many return statements within this function.
    Open

            return (fam.name, code)  # text before : doesn't match any known prefix
    Severity: Major
    Found in pywikibot/page/_links.py - About 30 mins to fix

      There are no issues that match your filters.

      Category
      Status