elliotwutingfeng/Inversion-DNSBL-Generator

View on GitHub

Showing 12 of 12 total issues

Function process_flags has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

def process_flags(parser_args: dict) -> None:
    """Run DNSBL generator tasks in sequence based on
    `parser_args` flags set by user.

    Args:
Severity: Minor
Found in modules/process_flags.py - About 4 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

File safebrowsing.py has 335 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
Safe Browsing API helper class
"""

import asyncio
Severity: Minor
Found in modules/safebrowsing.py - About 4 hrs to fix

    Function get_malicious_url_hash_prefixes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_malicious_url_hash_prefixes(self, threat_list_updates: dict) -> set[str]:
            """Download latest b64 encoded malicious URL hash prefixes from Safe Browsing API.
    
            The uncompressed threat entries in hash format of a particular prefix length.
            Hashes can be anywhere from 4 to 32 bytes in size. A large majority are 4 bytes,
    Severity: Minor
    Found in modules/safebrowsing.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 initialise_databases has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

    def initialise_databases(
        db_filenames: list[str] | None = None,
        mode: DatabaseTableModes = "hashes",
    ) -> None:
        """If `mode` is set to "domains" or "ips", create database for
    Severity: Minor
    Found in modules/database/create_table.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

    Avoid deeply nested control flow statements.
    Open

                            if chunk is None:
                                raise aiohttp.client_exceptions.ClientError(
                                    "Stream disrupted"
                                )
                            else:
    Severity: Major
    Found in modules/utils/http_requests.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          for row in reader:
                              raw_urls.append(row[0])
                      for batch in chunked(raw_urls, hostname_expression_batch_size):
      Severity: Major
      Found in modules/feeds/afnic.py - About 45 mins to fix

        Function retrieve_malicious_urls has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def retrieve_malicious_urls(urls_db_filenames: list[str], vendor: Vendors) -> list[str]:
            """Retrieve URLs from database most recently marked as malicious by Safe Browsing API
            of `vendor`.
        
            Args:
        Severity: Minor
        Found in modules/database/select.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

        Function _retrieve_domainsproject_txt_filepaths_and_db_filenames has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def _retrieve_domainsproject_txt_filepaths_and_db_filenames() -> (
            tuple[list[str], list[str]]
        ):
            """Scan for Domains Project .txt source files and generate filepaths
            to .txt source files, and database filenames for each .txt source file.
        Severity: Minor
        Found in modules/feeds/domainsproject.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

        Function generate_hostname_expressions_ has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

        def generate_hostname_expressions_(raw_url: str) -> list[str]:
            """Generate Safe Browsing API-compliant hostname expressions
            for a given `raw_url`
        
            Args:
        Severity: Minor
        Found in modules/utils/feeds.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

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

        def replace_malicious_url_full_hashes(
            full_hashes: Iterator[str], vendor: Vendors
        ) -> None:
            """Replace maliciousFullHashes table contents with latest malicious URL
            full hashes from Safe Browsing API
        Severity: Minor
        Found in modules/database/insert.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 execute_with_ray has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def execute_with_ray(
            task_handler: Callable,
            task_args_list: Sequence[tuple],
            object_store: Mapping | None = None,
            progress_bar: bool = True,
        Severity: Minor
        Found in modules/utils/parallel_compute.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def __init__(self, parser_args: dict, update_time: int):
                self.db_filenames: list[str] = []
                self.jobs: list[tuple] = []
        
                if "ec2" in parser_args["sources"]:
        Severity: Minor
        Found in modules/feeds/aws_ec2.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