tuomas2/serviceform

View on GitHub

Showing 45 of 197 total issues

File serviceform.py has 526 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
# (c) 2017 Tuomas Airaksinen
#
# This file is part of Serviceform.
#
Severity: Major
Found in serviceform/serviceform/models/serviceform.py - About 1 day to fix

    Function clean has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

        def clean(self):
            for key, value in self.post_data.items():
                if key.startswith('SRV_'):
                    parts = key.split('_')
                    if 'EXTRA' in parts:
    Severity: Minor
    Found in serviceform/serviceform/forms.py - About 7 hrs 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

    File forms.py has 470 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    # -*- coding: utf-8 -*-
    # (c) 2017 Tuomas Airaksinen
    #
    # This file is part of Serviceform.
    #
    Severity: Minor
    Found in serviceform/serviceform/forms.py - About 7 hrs to fix

      Function shuffle_person_data has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
      Open

      def shuffle_person_data(service_form: 'ServiceForm') -> None:
          from .models import Participant, ResponsibilityPerson, Question
          letters = len(string.ascii_letters)
          forenames = set()
          surnames = set()
      Severity: Minor
      Found in serviceform/serviceform/utils.py - About 7 hrs 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 init_serviceform_counters has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

      def init_serviceform_counters(service_form: 'ServiceForm', all_responsibles: bool=True) -> None:
          """
          Initializes counters and collects responsibles from subitems
      
          :return:
      Severity: Minor
      Found in serviceform/serviceform/utils.py - About 6 hrs 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 areYouSure has 144 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        $.fn.areYouSure = function(options) {
            
          var settings = $.extend(
            {
              'message' : 'You have unsaved changes!',
      Severity: Major
      Found in serviceform/serviceform/static/jquery.are-you-sure.js - About 5 hrs to fix

        Function menu_items has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
        Open

        def menu_items(context: Context, menu_name: str) -> MenuItems:
            """
            This is used for:
             - Reports menu
             - Participation password_login page menu
        Severity: Minor
        Found in serviceform/serviceform/templatetags/serviceform_tags.py - About 3 hrs 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

        File utils.py has 307 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        # -*- coding: utf-8 -*-
        # (c) 2017 Tuomas Airaksinen
        #
        # This file is part of Serviceform.
        #
        Severity: Minor
        Found in serviceform/serviceform/utils.py - About 3 hrs to fix

          File people.py has 289 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          # (c) 2017 Tuomas Airaksinen
          #
          # This file is part of Serviceform.
          #
          Severity: Minor
          Found in serviceform/serviceform/models/people.py - About 2 hrs to fix

            File settings.py has 285 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import os
            import socket
            import sys
            from logging.config import dictConfig
            from django.utils.translation import ugettext_lazy as _
            Severity: Minor
            Found in serviceform_project/settings.py - About 2 hrs to fix

              Participant has 25 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class Participant(ContactDetailsMixin, PasswordMixin, models.Model):
                  email: str
              
                  class Meta:
                      verbose_name = _('Participant')
              Severity: Minor
              Found in serviceform/serviceform/models/people.py - About 2 hrs to fix

                File admin.py has 282 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                # -*- coding: utf-8 -*-
                # (c) 2017 Tuomas Airaksinen
                #
                # This file is part of Serviceform.
                #
                Severity: Minor
                Found in serviceform/serviceform/admin.py - About 2 hrs to fix

                  Function require_authenticated_participant has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def require_authenticated_participant(function=None, check_flow=True):
                      def actual_decorator(func):
                          @wraps(func)
                          def wrapper(request: HttpRequest, *args, title: str='', **kwargs) -> HttpResponse:
                              current_view = request.resolver_match.view_name
                  Severity: Minor
                  Found in serviceform/serviceform/views/decorators.py - About 2 hrs 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 clean has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def clean(self):
                          had_values = set()
                          for key, value in self.data.items():
                              if key.startswith('SRV_'):
                                  parts = key.split('_')
                  Severity: Minor
                  Found in serviceform/serviceform/forms.py - About 2 hrs 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 construct_change_message has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def construct_change_message(self, request, form, formsets, add=False):
                          """Construct a change message from a changed object.
                          Copy of contrib/admin/options.py class ModelAdmin with get_text_list
                          replaced with self.get_field_change."""
                          change_message = []
                  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 participation has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def participation(request: HttpRequest, participant: models.Participant,
                                    cat_num: int) -> HttpResponse:
                      cat_num = int(cat_num)
                      service_form = participant.form
                      service_form.init_counters()
                  Severity: Minor
                  Found in serviceform/serviceform/views/participation_views.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 send_email_to_responsibles has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def send_email_to_responsibles(self) -> None:
                          """
                          Go through choices, activities, their categories and send email to responsibles.
                  
                          :return:
                  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 getValue has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      var getValue = function($field) {
                        if ($field.hasClass('ays-ignore')
                            || $field.hasClass('aysIgnore')
                            || $field.attr('data-ays-ignore')
                            || $field.attr('name') === undefined) {
                  Severity: Minor
                  Found in serviceform/serviceform/static/jquery.are-you-sure.js - About 1 hr to fix

                    Function create_email_templates has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def create_email_templates(self) -> None:
                            if not self.pk:
                                logger.error('Cannot create email template if form is not saved')
                                return
                    
                    
                    Severity: Minor
                    Found in serviceform/serviceform/models/serviceform.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 _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:
                    Severity: Minor
                    Found in serviceform/serviceform/forms.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

                    Severity
                    Category
                    Status
                    Source
                    Language