dnstats/dnstatsio

View on GitHub
dnstats/dnsutils/__init__.py

Summary

Maintainability
B
6 hrs
Test Coverage

Try, Except, Pass detected.
Open

    except:
Severity: Info
Found in dnstats/dnsutils/__init__.py by bandit

Try, Except, Pass detected.
Open

    except:
Severity: Info
Found in dnstats/dnsutils/__init__.py by bandit

Function get_dmarc_stats has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def get_dmarc_stats(ans):
    aggregate = False
    forensic = False
    dmarc = False
    policy = ""
Severity: Minor
Found in dnstats/dnsutils/__init__.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

Function caa_stats has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def caa_stats(ans):
    has_reporting = False
    has_caa = False
    allows_wildcard = False
    issue_count = 0
Severity: Minor
Found in dnstats/dnsutils/__init__.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 get_provider_from_ns_records has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def get_provider_from_ns_records(ans: list, site: str) -> int:
    if ans:
        ns_string = ''.join(ans).lower()
        if ns_string.endswith(site + '.'):
            return db_session.query(models.DnsProvider).filter_by(search_regex='Self-hosted').one().id
Severity: Minor
Found in dnstats/dnsutils/__init__.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 query_name_server has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def query_name_server(dns_server_ips: list, domain: str, request_type: str) -> []:
    """
    Do a query with a given name server, domain, and request type

    :param dns_server_ips: IP addresses of the name servers to use
Severity: Minor
Found in dnstats/dnsutils/__init__.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

Refactor this function to reduce its Cognitive Complexity from 28 to the 15 allowed.
Open

def get_dmarc_stats(ans):
Severity: Critical
Found in dnstats/dnsutils/__init__.py by sonar-python

Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

See

Do not use bare 'except'
Open

    except:
Severity: Minor
Found in dnstats/dnsutils/__init__.py by pep8

When catching exceptions, mention specific exceptions when possible.

Okay: except Exception:
Okay: except BaseException:
E722: except:

Do not use bare 'except'
Open

    except:
Severity: Minor
Found in dnstats/dnsutils/__init__.py by pep8

When catching exceptions, mention specific exceptions when possible.

Okay: except Exception:
Okay: except BaseException:
E722: except:

There are no issues that match your filters.

Category
Status