tuomas2/serviceform

View on GitHub

Showing 45 of 197 total issues

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)
Severity: Minor
Found in serviceform/serviceform/admin.py - About 1 hr to fix

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):
Severity: Minor
Found in serviceform/serviceform/templatetags/serviceform_tags.py - About 1 hr to fix

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) {
Severity: Minor
Found in serviceform/serviceform/static/jquery.are-you-sure.js - About 1 hr to fix

    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).
    Severity: Minor
    Found in serviceform/serviceform/models/people.py - About 1 hr to fix

    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,
    Severity: Minor
    Found in serviceform/serviceform/views/decorators.py - About 1 hr to fix

    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 = []
    Severity: Minor
    Found in serviceform/serviceform/templatetags/serviceform_tags.py - About 1 hr to fix

    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]
    Severity: Minor
    Found in serviceform/serviceform/admin.py - About 55 mins to fix

    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)
    Severity: Minor
    Found in serviceform/serviceform/views/participation_views.py - About 55 mins to fix

    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)
    Severity: Minor
    Found in serviceform/serviceform/models/serviceform.py - About 55 mins to fix

    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 all_responsibles:
                            choice._responsibles.update(set(activity.responsibles.all()) |
                                                        set(cat1.responsibles.all()) |
                                                        set(cat2.responsibles.all()))
    
    
    Severity: Major
    Found in serviceform/serviceform/utils.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not choice.skip_numbering:
                              choice_counter += 1
                          choice._counter = choice_counter
      Severity: Major
      Found in serviceform/serviceform/utils.py - About 45 mins to fix

        Function make has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def make(cls, name: str, form: 'ServiceForm', content: str, subject: str):
        Severity: Minor
        Found in serviceform/serviceform/models/email.py - About 35 mins to fix

          Function serviceform has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

          def serviceform(function=None, check_form_permission=False, init_counters=False,
          Severity: Minor
          Found in serviceform/serviceform/views/decorators.py - About 35 mins to fix

            Function save_model has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def save_model(self, request: HttpRequest, obj: models.ServiceForm, form, change: bool):
            Severity: Minor
            Found in serviceform/serviceform/admin.py - About 35 mins to fix

              Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def __init__(self, request: HttpRequest, participant: models.Participant,
              Severity: Minor
              Found in serviceform/serviceform/forms.py - About 35 mins to fix

                Function save_related has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def save_related(self, request: HttpRequest, form, formsets, change: bool):
                Severity: Minor
                Found in serviceform/serviceform/admin.py - About 35 mins to fix

                  Function make has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def make(cls, method: Callable, *args, scheduled_time: 'datetime'=None, **kwargs):
                  Severity: Minor
                  Found in serviceform/tasks/models.py - About 35 mins to fix

                    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def __init__(self, participant: models.Participant, user: 'AbstractUser',
                    Severity: Minor
                    Found in serviceform/serviceform/forms.py - About 35 mins to fix

                      Function map_field_value has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                          def map_field_value(self, values, choices):
                              def do_map(value, choices):
                                  if value is None:
                                      return '?'
                                  elif isinstance(value, Model):
                      Severity: Minor
                      Found in serviceform/serviceform/admin.py - About 35 mins to fix

                      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_ident has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                      Open

                      def _get_ident(request: HttpRequest) -> str:
                          service_form = getattr(request, 'service_form', '')
                          if not service_form:
                              logger.error('No serviceform in _get_ident!?')
                      
                      
                      Severity: Minor
                      Found in serviceform/serviceform/utils.py - About 35 mins to fix

                      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

                      Severity
                      Category
                      Status
                      Source
                      Language