Showing 49 of 232 total issues
Function get_spf_stats
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_spf_stats(ans: list) -> dict:
"""
:param ans:
:return:
- 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
Avoid deeply nested control flow statements. Open
if len(sites_chunked_update) >= 100:
chunk_count += 1
# loop counter to monitor task creation status
logger.debug("existing_sites chunk count: {}".format(chunk_count))
logger.info("Creating update task: {}".format(chunk_count))
Avoid deeply nested control flow statements. Open
for r in ans:
if r.startswith('"v=spf'):
return r
return ''
Function main
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def main():
with open('mx_records.txt', 'r') as f:
domains = dict()
for line in f:
line = line.replace("{", '').replace('}', '').strip()
- 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 grade_dmarc
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def grade_dmarc(site_run_id: int):
site, site_run = get_site_and_site_run(site_run_id)
records = site_run.j_dmarc_record
grade = 0
dmarcs = list()
- 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
Avoid deeply nested control flow statements. Open
if rf != 'afrf':
errors.append(DmarcErrors.INVALID_RF_VALUE)
elif tag == 'ri':
Function after_return
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def after_return(self, status, retval, task_id, args, kwargs, einfo):
Avoid deeply nested control flow statements. Open
if record.startswith('v=spf1 '):
if not has_spf:
for spf_part in record.split(' '):
parts_to_consider.append(spf_part)
has_spf = True
Function _run_report
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _run_report(query: str, report: str, adoption: bool, run_id: int, random_colors=False):
Function extract_spf_from_txt
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def extract_spf_from_txt(txt_records: list, domain: str):
spfs = list()
errors = list()
if not txt_records:
errors.append(SpfError.NO_SPF_FOUND)
- 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 grade
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def grade(mxs: list, domain: str) -> [int, list]:
mx = Mx(mxs)
if MXErrors.NO_MX_RECORDS in mx.errors or len(mx.valid_mx_records) == 0:
return 0, mx.errors
- 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
Function grade
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def grade(bimis: list, dmarcs: list, domain: str) -> [int, ()]:
if not bimis:
return 0, [BimiErrors.N0_BIMI_RECORDS]
the_bimis = []
- 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
Avoid too many return
statements within this function. Open
return 'B-'
Avoid too many return
statements within this function. Open
return 'D-'
Avoid too many return
statements within this function. Open
return result
Avoid too many return
statements within this function. Open
return 'C-'
Avoid too many return
statements within this function. Open
return 'D'
Avoid too many return
statements within this function. Open
return max(final_grade - (5 * len(soa.errors)), 0), soa.errors