twschiller/open-synthesis

View on GitHub

Showing 26 of 36 total issues

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

"""Analysis of Competing Hypotheses Django Application Model Configuration.

For more information, please see:
    https://docs.djangoproject.com/en/1.10/topics/db/models/
"""
Severity: Major
Found in openach/models.py - About 1 day to fix

    File boards.py has 390 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import itertools
    import json
    import logging
    import random
    from collections import defaultdict
    Severity: Minor
    Found in openach/views/boards.py - About 5 hrs to fix

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

      """
      Django settings for openintel project.
      
      Generated by 'django-admin startproject' using Django 1.10.
      
      
      Severity: Minor
      Found in openintel/settings.py - About 4 hrs to fix

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

        from django.conf import settings
        from django.contrib import messages
        from django.contrib.auth.decorators import login_required
        from django.contrib.auth.models import User
        from django.contrib.sites.shortcuts import get_current_site
        Severity: Minor
        Found in openach/views/teams.py - About 3 hrs to fix

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

          def comparison_style(user, aggregate):
              """Return the CSS class name for the analysis cell given a user evaluation and the consensus evaluation.
          
              Requires that the user disagrees with the consensus. If the user roughly agrees, return the weak consistent
              or inconsistent CSS class. Otherwise, return the dispute style depending on the distance between the evaluations.
          Severity: Minor
          Found in openach/templatetags/board_extras.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 handle has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              def handle(self, *args, **options):
                  """Handle the command invocation."""
                  if options["frequency"] == "daily":
                      self.report(send_digest_emails(DigestFrequency.daily))
                  elif options["frequency"] == "weekly":
          Severity: Minor
          Found in openach/management/commands/senddigest.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 edit_board has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

          def edit_board(request, board_id):
              """Return a board edit view, or handle the form submission."""
              board = get_object_or_404(Board, pk=board_id)
          
              if "edit_board" not in board.permissions.for_user(request.user):
          Severity: Minor
          Found in openach/views/boards.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 evaluate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

          def evaluate(request, board_id, evidence_id):
              """Return a view for assessing a piece of evidence against all hypotheses.
          
              Take a couple measures to reduce bias: (1) do not show the analyst their previous assessment, and (2) show
              the hypotheses in a random order.
          Severity: Minor
          Found in openach/views/boards.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 user.is_staff or is_owner:
                      return set(max_allowed)
                  else:
                      is_user_collaborator = self.collaborators.filter(pk=user.id).exists()
                      is_team_collaborator = self.teams.filter(members__pk=user.id).exists()
          Severity: Major
          Found in openach/models.py - About 1 hr to fix

            Function for_user has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

                def for_user(self, user):
                    """Return board authorization scheme for the given user.
            
                    If user is not authenticated, only the read_board and read_comments can be made available. NOTE: global public
                    access should be controlled via the ACCOUNT_REQUIRED settings.
            Severity: Minor
            Found in openach/models.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 add_evidence has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
            Open

            def add_evidence(request, board_id):
                """Return a view of adding evidence (with a source), or handle the form submission."""
                board = get_object_or_404(Board, pk=board_id)
            
                if "add_elements" not in board.permissions.for_user(request.user):
            Severity: Minor
            Found in openach/views/evidence.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 detail has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

            def detail(request, board_id, dummy_board_slug=None):
                """Return a detail view for the given board.
            
                Evidence is sorted in order of diagnosticity. Hypotheses are sorted in order of consistency.
                """
            Severity: Minor
            Found in openach/views/boards.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

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

            def parse_metadata(html):
                """Return document metadata from Open Graph, meta, and title tags.
            
                If title Open Graph property is not set, uses the document title tag. If the description Open Graph property is
                not set, uses the description meta tag.
            Severity: Minor
            Found in openach/tasks.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

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

            def invite_members(request, team_id):
                """Return a team edit view, or handle the form submission."""
                team = get_object_or_404(Team, pk=team_id)
            
                if team.owner_id is None or team.owner_id != request.user.id:
            Severity: Minor
            Found in openach/views/teams.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

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

            def send_digest_emails(digest_frequency):
                """Send daily digests to users subscribed to digests with frequency digest_frequency.
            
                :return tuple containing number of emails successfully sent and number that failed to send
                """
            Severity: Minor
            Found in openach/digest.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

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

                def clean(self):
                    """Validate the BoardPermissions model.
            
                    Check that the read permission is valid with respect to the relative to the global ACCOUNT_REQUIRED setting.
                    Check that the other permissions are valid relative to
            Severity: Minor
            Found in openach/models.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

            Consider simplifying this complex logical expression.
            Open

                if non_na and user.value < 3 and aggregate.value < 3:
                    return "eval-inconsistent"
                elif non_na and user.value > 3 and aggregate.value > 3:
                    return "eval-consistent"
                elif user.value == 0 or aggregate.value == 0:
            Severity: Major
            Found in openach/templatetags/board_extras.py - About 40 mins to fix

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

              def join_team(request, team_id):
                  team = get_object_or_404(Team, pk=team_id)
              
                  if team.members.filter(id=request.user.id).exists():
                      raise SuspiciousOperation(_("User is already a member of the team"))
              Severity: Minor
              Found in openach/views/teams.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 notification_digest has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def notification_digest(user, start, end):
                  """Return digest for user with content/notifications occurring after start.
              
                  Notifications are grouped by target, e.g., board.
              
              
              Severity: Minor
              Found in openach/digest.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 create_board has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              def create_board(request):
                  """Return a board creation view, or handle the form submission.
              
                  Set default permissions for the new board. Mark board creator as a board follower.
                  """
              Severity: Minor
              Found in openach/views/boards.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