Try, Except, Pass detected. Open
except:
- Exclude checks
Try, Except, Pass detected. Open
except:
- Exclude checks
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 = ""
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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):
- Read upRead up
- Exclude checks
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:
- Read upRead up
- Exclude checks
When catching exceptions, mention specific exceptions when possible.
Okay: except Exception:
Okay: except BaseException:
E722: except:
Do not use bare 'except' Open
except:
- Read upRead up
- Exclude checks
When catching exceptions, mention specific exceptions when possible.
Okay: except Exception:
Okay: except BaseException:
E722: except: