MPASolutions/django-webix-sender

View on GitHub

Showing 18 of 38 total issues

Function send_mixin has a Cognitive Complexity of 69 (exceeds 5 allowed). Consider refactoring.
Open

def send_mixin(send_method: str, typology: Optional[int], subject: str, body: str, recipients: Dict[str, List[int]],
               presend: Optional[Any], **kwargs) -> Tuple[Dict[str, Any], int]:
    """
    Function to send the message

Severity: Minor
Found in django_webix_sender/utils.py - About 1 day 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 has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self, request, *args, **kwargs):
        """
        Funzione che ritorna un JSON con i record del ContentType passato come parametro.

        Se nella richiesta viene passata una lista di ID e nel file `settings.py` è abilitato l'utilizzo dei filtri
Severity: Minor
Found in django_webix_sender/views.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 check_state has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

    def check_state(order_id, times=1, interval=60 * 5):
        def _state(_gateway, _order_id):
            from django_webix_sender.models import MessageRecipient, MessageSent

            # ### Funzione per aggiornare lo stato dei log degli sms
Severity: Minor
Found in django_webix_sender/send_methods/skebby.py - About 4 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 views.py has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import json
Severity: Minor
Found in django_webix_sender/views.py - About 3 hrs to fix

    Function get_context_data has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_context_data(self, **kwargs):
            context = super(InvoiceManagement, self).get_context_data(**kwargs)
    
            _send_methods = {}
            for i in CONF['send_methods']:
    Severity: Minor
    Found in django_webix_sender/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_sms has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def send_sms(recipients, body, message_sent):
        if 'django_webix_sender' not in settings.INSTALLED_APPS:
            raise Exception("Django Webix Sender is not in INSTALLED_APPS")
    
        from django_webix_sender.models import MessageRecipient, MessageSent
    Severity: Minor
    Found in django_webix_sender/send_methods/skebby.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 has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def send_email(recipients, subject, body, message_sent):
        # Controllo correttezza parametri
        if not isinstance(recipients, dict) or \
            'valids' not in recipients or not isinstance(recipients['valids'], list) or \
            'duplicates' not in recipients or not isinstance(recipients['duplicates'], list) or \
    Severity: Minor
    Found in django_webix_sender/send_methods/email.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

    Consider simplifying this complex logical expression.
    Open

        if not isinstance(recipients, dict) or \
            'valids' not in recipients or not isinstance(recipients['valids'], list) or \
            'duplicates' not in recipients or not isinstance(recipients['duplicates'], list) or \
            'invalids' not in recipients or not isinstance(recipients['invalids'], list):
            raise Exception("`recipients` must be a dict")
    Severity: Major
    Found in django_webix_sender/send_methods/skebby.py - About 1 hr to fix

      Consider simplifying this complex logical expression.
      Open

          if not isinstance(recipients, dict) or \
              'valids' not in recipients or not isinstance(recipients['valids'], list) or \
              'duplicates' not in recipients or not isinstance(recipients['duplicates'], list) or \
              'invalids' not in recipients or not isinstance(recipients['invalids'], list):
              raise Exception("`recipients` must be a dict")
      Severity: Major
      Found in django_webix_sender/send_methods/email.py - About 1 hr to fix

        Function send_mixin has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

        def send_mixin(send_method: str, typology: Optional[int], subject: str, body: str, recipients: Dict[str, List[int]],
        Severity: Major
        Found in django_webix_sender/utils.py - About 50 mins to fix

          Function send has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def send(self, recipients, message, message_type='basic', parametric=False, **kwargs):
                  """Sends an SMS"""
          
                  if message_type == 'classic':
                      message_type = 'TI'
          Severity: Minor
          Found in django_webix_sender/send_methods/skebby.py - About 45 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

                                  for field in i.split('__'):
                                      if _value is None:
                                          break
                                      _value = getattr(_value, field)
                                  try:
          Severity: Major
          Found in django_webix_sender/views.py - About 45 mins to fix

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

                def send(self, recipients, message, message_type='basic', parametric=False, **kwargs):
            Severity: Minor
            Found in django_webix_sender/send_methods/skebby.py - About 35 mins to fix

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

              def field_type(context, model, field_name):
                  app_label, model = model.split(".")
                  model_class = apps.get_model(app_label=app_label, model_name=model)
                  field = None
                  for name in field_name.split('__'):
              Severity: Minor
              Found in django_webix_sender/templatetags/field_type.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_verbose_field_name has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_verbose_field_name(context, model, field_name):
                  """ Returns verbose_name for a field. """
              
                  app_label, model = model.split(".")
                  model_class = apps.get_model(app_label=app_label, model_name=model)
              Severity: Minor
              Found in django_webix_sender/templatetags/verbose_name.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

              Avoid too many return statements within this function.
              Open

                      return JsonResponse({})
              Severity: Major
              Found in django_webix_sender/views.py - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                        return {'status': _('Invalid send method')}, 400
                Severity: Major
                Found in django_webix_sender/utils.py - About 30 mins to fix

                  Function ready has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def ready(self):
                          from django_webix_sender.settings import CONF
                          from django_webix_sender.utils import my_import
                  
                          if CONF is None:
                  Severity: Minor
                  Found in django_webix_sender/apps.py - About 25 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