Dallinger/Dallinger

View on GitHub

Showing 224 of 1,036 total issues

File docker_ssh.py has 759 lines of code (exceeds 750 allowed). Consider refactoring.
Open

import hashlib
import io
import json
import logging
import os
Severity: Major
Found in dallinger/command_line/docker_ssh.py - About 2 hrs to fix

Function deploy_heroku_docker has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def deploy_heroku_docker(log, verbose=True, app=None, exp_config=None):
    from dallinger.docker.tools import build_image

    config = get_config()
    config.load()
Severity: Major
Found in dallinger/command_line/docker.py - About 2 hrs to fix

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

    def is_supported(self, user_agent_string):
        """Check user agent against configured exclusions."""
        user_agent_obj = user_agents.parse(user_agent_string)
        browser_ok = True
        for rule in self.exclusions:
Severity: Minor
Found in dallinger/experiment_server/utils.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 tileMatchesAvailable has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

GameManager.prototype.tileMatchesAvailable = function () {
  var self = this;

  var tile;

Severity: Minor
Found in demos/dlgr/demos/twentyfortyeight/static/scripts/game_manager.js - 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 vectors has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def vectors(self, direction="all", failed=False):
        """Get vectors that connect at this node.

        Direction can be "incoming", "outgoing" or "all" (default).
        Failed can be True, False or all
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 serialized has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def serialized(func):
    """Run a function within a db transaction using SERIALIZABLE isolation.

    With this isolation level, committing will fail if this transaction
    read data that was since modified by another transaction. So we need
Severity: Minor
Found in dallinger/db.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 _ensure_mturk_qualifications has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def _ensure_mturk_qualifications(self, qualifications):
        """Create MTurk Qualifications for names that don't already exist,
        but also return names that already do.
        """
        result = {"new_qualifications": [], "existing_qualifications": []}
Severity: Minor
Found in dallinger/recruiters.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 deploy has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def deploy(
    image_name, mode, server, dns_host, app_name, config_options, archive_path, update
):  # pragma: no cover
    """Deploy a dallinger experiment docker image to a server using ssh."""
    config = get_config()
Severity: Major
Found in dallinger/command_line/docker_ssh.py - About 2 hrs to fix

Consider simplifying this complex logical expression.
Open

                if (
                    (rule == "mobile" and user_agent_obj.is_mobile)
                    or (rule == "tablet" and user_agent_obj.is_tablet)
                    or (rule == "touchcapable" and user_agent_obj.is_touch_capable)
                    or (rule == "pc" and user_agent_obj.is_pc)
Severity: Critical
Found in dallinger/experiment_server/utils.py - About 2 hrs to fix

Function published_study has 16 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def published_study(
Severity: Major
Found in dallinger/prolific.py - About 2 hrs to fix

Function verify_config has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def verify_config(verbose=True):
    """Check for common or costly errors in experiment configuration."""
    ok = True
    config = get_config()
    if not config.ready:
Severity: Minor
Found in dallinger/command_line/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 table_data has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def table_data(
        self, table: str = "participant", polymorphic_identity: Optional[str] = None
    ):
        """Generates DataTablesJS data and configuration for the experiment. The data
        is compiled from the models' ``__json__`` methods, and can be customized by either
Severity: Minor
Found in dallinger/experiment.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 site_config_dir has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def site_config_dir(appname=None, appauthor=None, version=None, multipath=False):
    r"""Return full path to the user-shared data dir for this application.

        "appname" is the name of application.
            If None, just the system directory is returned.
Severity: Minor
Found in dallinger/command_line/appdirs.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 transmissions has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def transmissions(self, direction="outgoing", status="all", failed=False):
        """Get transmissions sent to or from this node.

        Direction can be "all", "incoming" or "outgoing" (default).
        Status can be "all" (default), "pending", or "received".
Severity: Minor
Found in dallinger/models.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 wrap_subprocess_call has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

def wrap_subprocess_call(func, wrap_stdout=True):
    @functools.wraps(func)
    def wrapper(*popenargs, **kwargs):
        out = kwargs.get("stdout", None)
        err = kwargs.get("stderr", None)
Severity: Minor
Found in dallinger/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 connect has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def connect(self, whom, direction="to"):
        """Create a vector from self to/from whom.

        Return a list of newly created vector between the node and whom.
        ``whom`` can be a specific node or a (nested) list of nodes. Nodes can
Severity: Minor
Found in dallinger/models.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 createParticipant has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  dlgr.createParticipant = function() {
    var url = "/participant";
    var data = {};
    var deferred = $.Deferred();
    if (dlgr.identity.entryInformation) {
Severity: Minor
Found in dallinger/frontend/static/scripts/dallinger2.js - About 1 hr to fix

Function deploy_image has 47 lines of code (exceeds 25 allowed). Consider refactoring.
Open

def deploy_image(image_name, mode, config_options):
    """Deploy Heroku app using a docker image and MTurk."""
    config = get_config()
    config.load()
    dashboard_user = config.get("dashboard_user", "admin")
Severity: Minor
Found in dallinger/command_line/docker.py - About 1 hr to fix

Function move has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

GameManager.prototype.move = function (direction) {
  // 0: up, 1: right, 2: down, 3: left
  var self = this;

  if (this.isGameTerminated()) return; // Don't do anything if the game's over
Severity: Minor
Found in demos/dlgr/demos/twentyfortyeight/static/scripts/game_manager.js - About 1 hr to fix

Function draw has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    function draw() {

        destroy();

        var data = getnNetwork();
Severity: Minor
Found in dallinger/frontend/static/scripts/network-monitor.js - About 1 hr to fix
Severity
Category
Status
Source
Language