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/
"""
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
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.
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
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.
- Read upRead up
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":
- Read upRead up
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):
- Read upRead up
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.
- Read upRead up
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()
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.
- Read upRead up
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):
- Read upRead up
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.
"""
- Read upRead up
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.
- Read upRead up
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:
- Read upRead up
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
"""
- Read upRead up
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
- Read upRead up
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:
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"))
- Read upRead up
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.
- Read upRead up
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.
"""
- Read upRead up
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"