Showing 267 of 577 total issues
Function save_model
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def save_model(self, request, obj, form, change):
# allows to place a new item at the right position, moving certain items up.
# if the display_order is zero, autoplace the item.
if obj.display_order:
- 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 organization_and_url_import
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def organization_and_url_import(flat_organizations: List[Dict[str, Any]]):
if not config.GOOGLE_MAPS_API_KEY:
log.warning("Warning: the google maps api key is not set, fallback geocoding of addresses will not happen.")
- 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 handle
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
organization_types = dict(OrganizationType.objects.all().values_list("pk", "name", flat=False))
matches = []
- 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 item_title
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def item_title(self, item):
rating = (
_("Perfect")
if not any([item["high"], item["medium"], item["low"]])
else _("High")
- 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 add_statistics_to_calculation
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_statistics_to_calculation(calculation, amount_of_issues):
# inject all kinds of statistics inside the json for easier(?) representation.
calculation["total_issues"] = amount_of_issues["overall"]["any"]
calculation["high"] = amount_of_issues["overall"]["high"]
calculation["medium"] = amount_of_issues["overall"]["medium"]
Function test_autoexplain_including_headers
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_autoexplain_including_headers(db, monkeypatch):
url, created = Url.objects.all().get_or_create(url="lyncdiscover.arnhem.nl")
endpoint, created = Endpoint.objects.all().get_or_create(url=url, protocol="https", port="443", ip_version=4)
endpointscan, created = EndpointGenericScan.objects.all().get_or_create(
endpoint=endpoint,
Function handle
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
"""Optionally run migrations and load data."""
try:
subprocess.check_call("command -v uwsgi", shell=True, stdout=subprocess.DEVNULL)
- 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 save_model
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def save_model(self, request, obj, form, change):
# log.info(form.changed_data)
# grrr, both area and edit_area are ALWAYS changed... even if you didn't change the values in these
# fields... this is obviously a bug or "optimization". We now have to resort to queries to figure out
- 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 remove_issues_from_calculation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def remove_issues_from_calculation(calculation, issues):
# todo: also recalculate here?
new_url_ratings = []
for url_rating in calculation["ratings"]:
if url_rating["type"] in issues:
- 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 test_plan_outdated_scans
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_plan_outdated_scans(db):
o = create_organization("Test")
u1 = create_url("example.com")
link_url_to_organization(u1, o)
u2 = create_url("example2.com")
Function test_plannedscan
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def test_plannedscan(db):
o = create_organization("Test")
u1 = create_url("example.com")
link_url_to_organization(u1, o)
u2 = create_url("example2.com")
Function analyze_headers
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def analyze_headers(headers: Dict[str, str], endpoint_id):
# todo: remove code paths, and make a more clear case per header type. That's easier to understand edge cases.
# todo: Content-Security-Policy, Referrer-Policy
# if scan task failed, ignore the result (exception) and report failed status
- 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 contests
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def contests(request):
if request.POST:
form = ContestForm(request.POST)
- 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 q_configurations_to_scan
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def q_configurations_to_scan(level: str = "url"):
"""
Retrieves configurations and makes q-queries for them. You can select if you want to have the q-queries directly
for the organization tables, or with a join from url to organization.
- 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 scan
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def scan(self, address: str, port: int):
"""
Uses the dnssec scanner of dotse, which works pretty well.
:param url:
- 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_actions
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_actions(self, request):
# using this function maker, scan functions can be generated.
def scan_function_maker(scanner_name, verbose_name):
def scan_function(self, *args, **kwargs):
- 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 docker_services
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def docker_services(pytestconfig, docker_ip):
"""Ensure all Docker-based services are up and running."""
docker_compose_file = os.path.join(str(pytestconfig.rootdir), "tests", "docker-compose.yml")
docker_compose_project_name = "pytest{}".format(os.getpid())
- 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 _handle
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _handle(self, *args, **options):
"""Ensure complete development environment is started."""
# unique ID for container name
uuid = uuid1()
- 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 run_task
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def run_task(self, *args, **options):
# try to compose task if not specified
if not self.task:
self.task = self.compose(*args, **options)
- 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 accept
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def accept(self, request, queryset):
for osm in queryset:
# don't add the same thing over and over, allows to re-select the ones already added without a problem
# once rejected, can't be accepted via buttons: needs to be a manual action
- 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"