john-kurkowski/tldextract

View on GitHub

Showing 9 of 9 total issues

File tldextract.py has 416 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""`tldextract` accurately separates a URL's subdomain, domain, and public suffix.

It does this via the Public Suffix List (PSL).

    >>> import tldextract
Severity: Minor
Found in tldextract/tldextract.py - About 6 hrs to fix

    Function clear has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def clear(self) -> None:
            """Clear the disk cache."""
            for root, _, files in os.walk(self.cache_dir):
                for filename in files:
                    if filename.endswith(self.file_ext) or filename.endswith(
    Severity: Minor
    Found in tldextract/cache.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 main has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def main() -> None:
        """Tldextract CLI main command."""
        logging.basicConfig()
    
        parser = argparse.ArgumentParser(
    Severity: Minor
    Found in tldextract/cli.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 suffix_index has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def suffix_index(
            self, spl: list[str], include_psl_private_domains: bool | None = None
        ) -> tuple[int, bool]:
            """Return the index of the first suffix label, and whether it is private.
    
    
    Severity: Minor
    Found in tldextract/tldextract.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 _extract_netloc has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def _extract_netloc(
            self,
            netloc: str,
            include_psl_private_domains: bool | None,
            session: requests.Session | None = None,
    Severity: Minor
    Found in tldextract/tldextract.py - About 45 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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in tldextract/tldextract.py - About 45 mins to fix

      Function _get_suffix_lists has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _get_suffix_lists(
      Severity: Minor
      Found in tldextract/suffix_list.py - About 35 mins to fix

        Function get_suffix_lists has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def get_suffix_lists(
        Severity: Minor
        Found in tldextract/suffix_list.py - About 35 mins to fix

          Function _make_dir has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

          def _make_dir(filename: str) -> None:
              """Make a directory if it doesn't already exist."""
              if not os.path.exists(os.path.dirname(filename)):
                  try:
                      os.makedirs(os.path.dirname(filename))
          Severity: Minor
          Found in tldextract/cache.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

          Severity
          Category
          Status
          Source
          Language