Showing 197 of 197 total issues
Function _fetch_instances
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def _fetch_instances(self) -> None:
categories = [self.category] if self.category else self.form.sub_items
for cat1 in categories:
for cat2 in cat1.sub_items:
- 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_form
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_form(self, request: HttpRequest, obj: models.ServiceForm=None, **kwargs):
form = super().get_form(request, obj, **kwargs)
if obj:
request._responsibles = responsibles = models.ResponsibilityPerson.objects.filter(
form=obj)
- 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 color_style
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def color_style(item: 'AbstractServiceFormItem', lighter=0, attr='background') -> SafeString:
color = item.background_color_display
if color:
if lighter < 0:
for i in range(-lighter):
- 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 checkForm
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
var checkForm = function(evt) {
var isFieldDirty = function($field) {
var origValue = $field.data('ays-orig');
if (undefined === origValue) {
Function can_access_view
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def can_access_view(self, view_name: str, auth: bool=False) -> bool:
"""
Access is granted to next view after last finished view
auth: if query is for authentication (if we can already really proceed to view or not).
- 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 serviceform
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def serviceform(function=None, check_form_permission=False, init_counters=False,
all_responsibles=True, fetch_participants=False):
def actual_decorator(func):
@wraps(func)
def wrapper(request: HttpRequest, slug: 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
Function participant_flow_menu_items
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def participant_flow_menu_items(context: Context) -> List[FlowItem]:
current_view = context['request'].resolver_match.view_name
participant = context['request'].participant
cat_num = context.get('cat_num', 0)
lst = []
- 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_field_change
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_field_change(self, form, changed_fields):
"""Mentions old and new value for changed fields"""
changes = []
for field_name in changed_fields:
field = form.fields[field_name]
- 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 contact_details
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def contact_details(request: HttpRequest, participant: models.Participant) -> HttpResponse:
if participant and participant.status == models.Participant.STATUS_FINISHED:
return HttpResponseRedirect(reverse('submitted'))
form = forms.ContactForm(instance=participant, user=request.user)
- 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 invite_user
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def invite_user(self, email: str, old_participants: bool=False) -> InviteUserResponse:
"""
Create new participations to current form version and send invites
:return: int (one of InviteUserResponse constants)
- 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
models.Participant.objects.filter(last_modified__lt=timezone.now() - timedelta(days=1),
status=models.Participant.STATUS_ONGOING).delete()
- 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 36.
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
for p in models.Participant.objects.filter(
last_modified__lt=timezone.now() - timedelta(days=1),
status=models.Participant.STATUS_UPDATING):
- 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 36.
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
Avoid deeply nested control flow statements. Open
if all_responsibles:
choice._responsibles.update(set(activity.responsibles.all()) |
set(cat1.responsibles.all()) |
set(cat2.responsibles.all()))
Avoid deeply nested control flow statements. Open
if not choice.skip_numbering:
choice_counter += 1
choice._counter = choice_counter
Function make
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def make(cls, name: str, form: 'ServiceForm', content: str, subject: str):
Function serviceform
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def serviceform(function=None, check_form_permission=False, init_counters=False,
Function save_model
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def save_model(self, request: HttpRequest, obj: models.ServiceForm, form, change: bool):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, request: HttpRequest, participant: models.Participant,
Function save_related
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def save_related(self, request: HttpRequest, form, formsets, change: bool):
Function make
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def make(cls, method: Callable, *args, scheduled_time: 'datetime'=None, **kwargs):