Showing 232 of 232 total issues
Function _validate_spf
has a Cognitive Complexity of 134 (exceeds 5 allowed). Consider refactoring. Open
def _validate_spf(spf: str, domain: str) -> {}:
errors = list()
if not spf.startswith('v=spf1 '):
errors.append(SpfError.INVALID_RECORD_START)
parts = spf.split(' ')
- 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 validate
has a Cognitive Complexity of 77 (exceeds 5 allowed). Consider refactoring. Open
def validate(dmarc_result_set: list) -> dict:
dmarc_record_values = dict()
tag_count = dict()
errors = list()
if len(dmarc_result_set) < 1:
- 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 validate
has a Cognitive Complexity of 56 (exceeds 5 allowed). Consider refactoring. Open
def validate(caa_result_set: list, domain: str) -> dict:
"""
Validate a CAA record set based on RFC 8659
:param caa_result_set: a list of CAA records as str
- 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
File celery.py
has 387 lines of code (exceeds 250 allowed). Consider refactoring. Open
import datetime
import os
from celery import Celery, Task
from celery.canvas import chain, group
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
File seed.py
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
import csv
import dnstats.db.models as models
from dnstats.db import db_session
Function _validate
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def _validate(self) -> {}:
result = {}
errors = []
validated_records = []
if not self.ns_records or len(self.ns_records) == 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_redirect_record
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def _get_redirect_record(record):
record = record.replace('"', '')
parts = record.split(' ')
for part in parts:
if part.startswith('redirect='):
- 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 _validate
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def _validate(self) -> dict:
result = dict()
result['errors'] = []
result['records'] = []
if not self.mx_records or len(self.mx_records) == 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 _validate
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def _validate(self, records: list) -> dict:
result = {}
self.errors = []
if not records or len(records) <= 0:
self.errors.append(BimiErrors.N0_BIMI_RECORDS)
- 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 import_list
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def import_list():
new_sites = setup_import_list(logger)
existing_sites = dict()
with engine.connect() as connection:
- 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 percent_to_letter
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def percent_to_letter(percent: float):
if percent > 100.0:
return 'A+'
elif percent >= 93.0:
return 'A'
- 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 site_stat
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def site_stat(site_id: int, run_id: int):
logger.debug('start site stat site {} run id {}'.format(site_id, run_id))
result = dict()
result['start_time'] = datetime.datetime.now()
site = db_session.query(models.Site).filter(models.Site.id == site_id).scalar()
Function grade
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def grade(dmarcs: list, domain: str) -> [int, ()]:
current_grade = 0
dmarc = Dmarc(dmarcs)
if dmarc.errors.__contains__(DmarcErrors.INVALID_DMARC_RECORD_START):
return 0, dmarc.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 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 validate
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def validate(self) -> {}:
result = {}
errors = []
if len(self.soas) == 0:
errors.append(SoaErrors.NO_SOA)
Function create_reports
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_reports(run_id: int):
spf_adoption_query = "select count(*) from site_runs sr " \
"where sr.run_id = {} and sr.has_spf is true".format(run_id)
securitytxt_adoption_query = "select count(*) from site_runs sr " \
Function publish_reports
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def publish_reports(run_id: int):
# sr is the alias for site_runs table
reports = list()
reports.append({'query': 'sr.mx_records is not null', 'name': 'mx_domains', 'type': 'list'})
reports.append({'query': 'sr.mx_records is null', 'name': 'no_mx_domains', 'type': 'list'})
Function grade
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def grade(spfs: list, domain: str, has_mx: True) -> [int, list]:
"""
Grade a given SPF for a given domain.
:param spfs: a list of txt records for the apex
:param domain: domain of the given SPF record
- 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_mx_records
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_provider_from_mx_records(ans: list, site: str) -> int:
if ans:
mx_string = ''.join(ans).lower()
if mx_string.endswith(site + '.'):
return db_session.query(models.EmailProvider).filter_by(search_regex='domain.').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"