Dallinger/Dallinger

View on GitHub

Showing 149 of 461 total issues

File experiment_server.py has 1457 lines of code (exceeds 750 allowed). Consider refactoring.
Open

""" This module provides the backend Flask server that serves an experiment. """

from datetime import datetime, timedelta
from functools import update_wrapper
import gevent
Severity: Major
Found in dallinger/experiment_server/experiment_server.py - About 2 days to fix

File models.py has 1304 lines of code (exceeds 750 allowed). Consider refactoring.
Open

"""Define Dallinger's core models."""

from datetime import datetime
import inspect

Severity: Major
Found in dallinger/models.py - About 1 day to fix

Function dallinger has 346 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var dallinger = (function () {
  /**
   * @namespace
   * @alias dallinger
   */
Severity: Major
Found in dallinger/frontend/static/scripts/dallinger2.js - About 1 day to fix

Function dallinger has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
Open

var dallinger = (function () {
  /**
   * @namespace
   * @alias dallinger
   */
Severity: Minor
Found in dallinger/frontend/static/scripts/dallinger2.js - 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

Experiment has 57 functions (exceeds 20 allowed). Consider refactoring.
Open

class Experiment(object):
    """Define the structure of an experiment."""

    app_id = None
    # Optional Redis channel to create and subscribe to on launch. Note that if
Severity: Major
Found in dallinger/experiment.py - About 1 day to fix

Function update_pins has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
Open

def update_pins(setup_args):
    # Use requirements and constraints to set version pins
    packages = set()
    constraint_files = []
    install_dir = os.path.dirname(__file__)
Severity: Minor
Found in setup_utils.py - About 5 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 handle_error has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

def handle_error():
    request_data = request.form.get("request_data")
    error_feedback = request.form.get("error_feedback")
    error_type = request.form.get("error_type")
    error_text = request.form.get("error_text")
Severity: Minor
Found in dallinger/experiment_server/experiment_server.py - About 5 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 has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
Open

ScribeDallingerTracker.prototype.init = function() {
  var config = this.config;
  var getNodeDescriptor = function(node) {
    return {
      id:         node.id,
Severity: Minor
Found in dallinger/frontend/static/scripts/tracking/scribe-dallinger.js - 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

MTurkService has 35 functions (exceeds 20 allowed). Consider refactoring.
Open

class MTurkService(object):
    """Facade for Amazon Mechanical Turk services provided via the boto3
       library.
    """

Severity: Minor
Found in dallinger/mturk.py - About 4 hrs to fix

Function worker_function has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

def worker_function(
    event_type, assignment_id, participant_id, node_id=None, details=None
):
    """Process the notification."""
    _config()
Severity: Minor
Found in dallinger/experiment_server/experiment_server.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

HerokuApp has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class HerokuApp(HerokuCommandRunner):
    """Representation of a Heroku app"""

    def __init__(self, dallinger_uid, output=None, team=None):
        self.dallinger_uid = dallinger_uid
Severity: Minor
Found in dallinger/heroku/tools.py - About 3 hrs to fix

Function init has 75 lines of code (exceeds 25 allowed). Consider refactoring.
Open

ScribeDallingerTracker.prototype.init = function() {
  var config = this.config;
  var getNodeDescriptor = function(node) {
    return {
      id:         node.id,
Severity: Major
Found in dallinger/frontend/static/scripts/tracking/scribe-dallinger.js - About 3 hrs to fix

Function is_connected has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def is_connected(self, whom, direction="to", failed=None):
        """Check whether this node is connected [to/from] whom.

        whom can be a list of nodes or a single node.
        direction can be "to" (default), "from", "both" or "either".
Severity: Minor
Found in dallinger/models.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 update has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  Game.prototype.update = function(dt) {
    var x, y;
    if (atom.input.pressed('move_left')) {
      if (this.dir !== "right") {
          this.newdir = "left";
Severity: Major
Found in demos/dlgr/demos/snake/static/scripts/stake.js - About 2 hrs to fix

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

class MTurkRecruiter(Recruiter):
    """Recruit participants from Amazon Mechanical Turk"""

    nickname = "mturk"

Severity: Minor
Found in dallinger/recruiters.py - About 2 hrs to fix

Function listen has 66 lines of code (exceeds 25 allowed). Consider refactoring.
Open

KeyboardInputManager.prototype.listen = function () {
  var self = this;

  var map = {
    38: 0, // Up

Function node_transmit has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

def node_transmit(node_id):
    """Transmit to another node.

    The sender's node id must be specified in the url.

Severity: Minor
Found in dallinger/experiment_server/experiment_server.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 transmit has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def transmit(self, what=None, to_whom=None):
        """Transmit one or more infos from one node to another.

        "what" dictates which infos are sent, it can be:
            (1) None (in which case the node's _what method is called).
Severity: Minor
Found in dallinger/models.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

File recruiters.py has 769 lines of code (exceeds 750 allowed). Consider refactoring.
Open

"""Recruiters manage the flow of participants to the experiment."""

import json
import logging
import os
Severity: Major
Found in dallinger/recruiters.py - About 2 hrs to fix

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

def crossdomain(
    origin=None,
    methods=None,
    headers=None,
    max_age=21600,
Severity: Minor
Found in dallinger/experiment_server/experiment_server.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

Severity
Category
Status
Source
Language