Showing 577 of 577 total issues
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return standard_calculation_for_internet_nl(scan=scan, explanation=scan.explanation, error_in_test=True)
Avoid too many return
statements within this function. Open
return operation_response(
Avoid too many return
statements within this function. Open
return standard_calculation(scan=scan, explanation=f"{scan.rating} {scan.evidence}", high=0, medium=1, low=0)
Avoid too many return
statements within this function. Open
return standard_calculation(scan=scan, explanation=explanation, high=0, medium=1, low=0)
Avoid too many return
statements within this function. Open
return '0.0.0'
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return existing_second_level_url.add_subdomain(extracted.subdomain, "added via SIDN")
Avoid too many return
statements within this function. Open
return operation_response(error=True, message="No longitude given, cannot add organization.")
Avoid too many return
statements within this function. Open
return operation_response(error=True, message="Latitude is between -180 and 180.")
Avoid too many return
statements within this function. Open
return response
Avoid too many return
statements within this function. Open
return amount_of_issues, judgement_issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
scans = list(
EndpointGenericScan.objects.all().filter(
endpoint__url__urlsubmission__added_by_team=team.id,
endpoint__url__urlsubmission__has_been_accepted=True,
rating_determined_on__lte=contest.until_moment,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 32.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
scans += list(
UrlGenericScan.objects.all().filter(
url__urlsubmission__added_by_team=team.id,
url__urlsubmission__has_been_accepted=True,
rating_determined_on__lte=contest.until_moment,
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 32.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function compose_discover_task
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def compose_discover_task(urls: List[Url]):
tasks = []
for ip_version in [4, 6]:
for port in PREFERRED_PORT_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 accept
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def accept(self, request, queryset):
for urlsubmission 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"
Further reading
Function handle
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle(self, *args, **options):
"""Command handle logic, eg: logging."""
# set django loglevel based on `-v` argument
verbosity = int(options["verbosity"])
root_logger = logging.getLogger("")
- 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_record
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate_record(record):
if not record.get("Name", ""):
ValueError('Missing "Name" column or column was empty.')
- 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 pickup
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def pickup(activity: str, scanner: str, amount: int = 10) -> List[Url]:
"""
Amount should not be too high: then this loses it's power and make scans invisible again. But it helps
with faster scanning as fewer queries are needed.
- 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 update_feature
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def update_feature(feature, scan):
# log.debug('Updating feature %s, with scan %s' % (feature['properties']['organization_id'], scan))
calculation = get_severity(scan)
feature["properties"]["high"] += calculation["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"