secynic/ipwhois

View on GitHub

Showing 100 of 266 total issues

Avoid deeply nested control flow statements.
Open

                        if key == 'contacts':

                            for k, v in val.items():

                                if v:
Severity: Major
Found in ipwhois/scripts/ipwhois_cli.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if (
                            ip in failed_lookups_dict.keys()
                        ):  # pragma: no cover

                            del failed_lookups_dict[ip]
Severity: Major
Found in ipwhois/experimental.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if ip not in failed_lookups_dict.keys():

                            failed_lookups_dict[ip] = 1

                        # This IP has already failed at least once, increment
Severity: Major
Found in ipwhois/experimental.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                    if rir == 'lacnic':

                        rate_tracker[rir]['count'] += 1

                    # Get the next proxy opener to use, or None
Severity: Major
Found in ipwhois/experimental.py - About 45 mins to fix

Function generate_output has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def generate_output(line='0', short=None, name=None, value=None,
Severity: Minor
Found in ipwhois/scripts/ipwhois_cli.py - About 45 mins to fix

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

    def get_asn_whois(self, retry_count=3):
        """
        The function for retrieving ASN information for an IP address from
        Cymru via port 43/tcp (WHOIS).

Severity: Minor
Found in ipwhois/net.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 lookup has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def lookup(self, nir=None, inc_raw=False, retry_count=3, response=None,
Severity: Minor
Found in ipwhois/nir.py - About 45 mins to fix

Function lookup has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def lookup(self, asn=None, inc_raw=False, retry_count=3, response=None,
Severity: Minor
Found in ipwhois/asn.py - About 45 mins to fix

Function parse_fields has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def parse_fields(self, response, fields_dict, net_start=None,
Severity: Minor
Found in ipwhois/whois.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        if rir == 'lacnic':

                            lacnic_total_left -= 1

Severity: Major
Found in ipwhois/experimental.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        for k, v in val.items():

                            if k in ['phone', 'address', 'email']:

                                output += generate_output(
Severity: Major
Found in ipwhois/scripts/ipwhois_cli.py - About 45 mins to fix

Avoid deeply nested control flow statements.
Open

                        for contact in val:

                            if contact in global_contacts.keys():

                                temp_net['contacts'][key] = (
Severity: Major
Found in ipwhois/nir.py - About 45 mins to fix

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

    def get_http_raw(self, url=None, retry_count=3, headers=None,
Severity: Minor
Found in ipwhois/net.py - About 35 mins to fix

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

    def get_contact(self, response=None, nir=None, handle=None,
Severity: Minor
Found in ipwhois/nir.py - About 35 mins to fix

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

    def parse_fields(self, response, fields_dict, net_start=None,
Severity: Minor
Found in ipwhois/asn.py - About 35 mins to fix

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

    def get_asn_origin_whois(self, asn_registry='radb', asn=None,
Severity: Minor
Found in ipwhois/net.py - About 35 mins to fix

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

    def get_whois(self, asn_registry='arin', retry_count=3, server=None,
Severity: Minor
Found in ipwhois/net.py - About 35 mins to fix

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

    def lookup(self, inc_raw=False, retry_count=3, extra_org_map=None,
Severity: Minor
Found in ipwhois/asn.py - About 35 mins to fix

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

    def __init__(
        self,
        addr,
        timeout,
        proxy_http,
Severity: Minor
Found in ipwhois/scripts/ipwhois_cli.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 get_nets_jpnic has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    def get_nets_jpnic(self, response):
        """
        The function for parsing network blocks from jpnic whois data.

        Args:
Severity: Minor
Found in ipwhois/nir.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

Severity
Category
Status
Source
Language