ejplatform/ej-server

View on GitHub

Showing 137 of 185 total issues

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

from django.core.paginator import PageNotAnInteger, EmptyPage
from django.apps import apps
from django.http import HttpResponse, Http404, JsonResponse
from typing import Callable

Severity: Minor
Found in src/ej_dataviz/utils.py - About 4 hrs to fix

    File models.py has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import requests
    import json
    from django.utils.translation import gettext_lazy as _
    
    # from boogie import models
    Severity: Minor
    Found in src/ej_tools/models.py - About 2 hrs to fix

      File views.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      from logging import getLogger
      
      from django.db import transaction
      from django.db.models import F
      from django.http import HttpResponse, HttpResponseServerError, JsonResponse
      Severity: Minor
      Found in src/ej_conversations/views.py - About 2 hrs to fix

        File cluster_queryset.py has 276 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        from logging import getLogger
        
        from boogie.models import QuerySet, F, Manager, Value, IntegerField
        from django.contrib.auth import get_user_model
        from sidekick import import_later
        Severity: Minor
        Found in src/ej_clusters/models/cluster_queryset.py - About 2 hrs to fix

          File conversation.py has 268 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from autoslug import AutoSlugField
          from boogie import models
          from boogie import rules
          from django.conf import settings
          from django.contrib.auth import get_user_model
          Severity: Minor
          Found in src/ej_conversations/models/conversation.py - About 2 hrs to fix

            Function AreaChart has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function AreaChart(voteData, color) {
              const curve = d3.curveLinear;
              const margin = { top: 20, right: 30, bottom: 30, left: 40 };
            
              let width = d3.select("#votes-over-time").attr("width");
            Severity: Major
            Found in lib/assets/js/conversations/votes-over-time.js - About 2 hrs to fix

              Function clean_migrations has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

              def clean_migrations(_ctx, all=False, yes=False):
                  """
                  Remove all automatically created migrations.
                  """
                  import re
              Severity: Minor
              Found in etc/tasklib/django_tasks.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 constructor has 53 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  constructor({size, intersections, radius = 50, pos = null, vel = null, isUserGroup = false, name = "Group"}) {
                      this.size = size;
                      this.intersections = intersections.slice();
                      this.radius = radius;
                      this.mass = (this.radius / 100) ** 2;
              Severity: Major
              Found in lib/js/clusterviz/shape.ts - About 2 hrs to fix

                Function summarize_affinities has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                Open

                def summarize_affinities(affinities):
                    """
                    Process the result of :func:`compute_cluster_affinities`
                    and returns a list of summaries for each cluster/intersection. This data
                    is exposed in the /api/v1/clusterizations/<id>/affinities/ as:
                Severity: Minor
                Found in src/ej_clusters/math/data.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 stereotype_votes has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                def stereotype_votes(request, conversation_id, **kwargs):
                    conversation = Conversation.objects.get(id=conversation_id)
                    clusterization = conversation.get_clusterization(default=None)
                    created_vote_id = None
                    if clusterization is None:
                Severity: Minor
                Found in src/ej_clusters/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 main has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                def main():
                    """
                    This code was taken and adapted from
                
                    django.core.management.commands.compilemessages
                Severity: Minor
                Found in etc/scripts/compilemessages.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 with_template has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                def with_template(model, role, template=None, queryset=False):
                    """
                    Decorator Register element rendered from a template.
                
                    Args:
                Severity: Minor
                Found in src/ej/roles/utils.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 _draw has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                        _draw: function() {
                            var    o = this.data('pagination'),
                                interval = methods._getInterval(o),
                                i;
                
                
                Severity: Minor
                Found in lib/assets/js/simplePagination.js - About 1 hr to fix

                  Function mautic has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def mautic(request, board_slug, conversation_id, slug, oauth2_code=None):
                      conversation = Conversation.objects.get(id=conversation_id)
                      user_signature = SignatureFactory.get_user_signature(conversation.author)
                      tool = user_signature.get_tool(_("Mautic"), conversation)
                      tool.raise_error_if_not_active()
                  Severity: Minor
                  Found in src/ej_tools/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 set_clusters_from_comments has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def set_clusters_from_comments(conversation, comment_map, exclusive=True, author=None):
                      """
                      Create clusters and stereotypes from conversation.
                  
                      Usage:
                  Severity: Minor
                  Found in src/ej_clusters/factories.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 statistics_summary_dataframe has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def statistics_summary_dataframe(
                          self,
                          normalization=1,
                          votes=None,
                          comments=None,
                  Severity: Minor
                  Found in src/ej_conversations/mixins.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 _stereotypes_votes_table has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _stereotypes_votes_table(self, mean, kind_col, cluster_col, **kwargs):
                          # Prepare stereotype votes
                          if mean:
                              stereotype_votes = self.mean_stereotypes_votes_table()
                          else:
                  Severity: Minor
                  Found in src/ej_clusters/models/cluster_queryset.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 watch_path has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def watch_path(path, func, poll_time=0.5, name=None, skip_first=False):
                      """
                      Watch path and execute the given function everytime a file changes.
                      """
                      import time
                  Severity: Minor
                  Found in etc/tasklib/base.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 cluster_votes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def cluster_votes(conversation, users):
                      clusterization = conversation.get_clusterization()
                      comments = list(conversation.comments.all())
                      comments_map = {comment.id: comment for comment in comments}
                      clusters = {cluster: [] for cluster in clusterization.clusters.all()}
                  Severity: Minor
                  Found in src/ej_clusters/factories.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 update_clusterization has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def update_clusterization(self, force=False, atomic=False):
                          """
                          Update clusters if necessary, unless force=True, in which it
                          unconditionally updates the clusterization.
                          """
                  Severity: Minor
                  Found in src/ej_clusters/models/clusterization.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