Dallinger/Dallinger

View on GitHub

Showing 224 of 1,036 total issues

Function __init__ has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def __init__(
Severity: Major
Found in dallinger/experiment_server/worker_events.py - About 1 hr to fix

Function open_chatroom has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

var open_chatroom = function () {
  var ws_scheme = (window.location.protocol === "https:") ? 'wss://' : 'ws://';
  // Setup a websocket connection to the "chatroom", passing our worker_id and participant_id
  chatroom_socket = new ReconnectingWebSocket(
    ws_scheme + location.host + "/chat?channel=chatroom&worker_id=" + dallinger.identity.workerId + '&participant_id=' + dallinger.identity.participantId
Severity: Minor
Found in demos/dlgr/demos/chatroom_ws/static/scripts/experiment.js - About 1 hr to fix

Function build_widget has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def build_widget(self):
        from ipywidgets import widgets

        start, end = self.experiment.usable_replay_range
        options = []
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 bot_recruits has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def bot_recruits(request, active_config, recruitment_loop):
    driver_type = request.param or "chrome_headless"
    active_config.set("webdriver_type", driver_type)

    def recruit_bots():
Severity: Minor
Found in dallinger/pytest_dallinger.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 clean_qualification_requirement has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def clean_qualification_requirement(self, requirement):
        attributes = requirement["attributes"]

        cleaned_attributes = [
            attribute
Severity: Minor
Found in dallinger/recruiters.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 database has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def database():
    from dallinger.db import get_polymorphic_mapping
    from dallinger.experiment_server.experiment_server import Experiment, session

    exp = Experiment(session)
Severity: Minor
Found in dallinger/experiment_server/dashboard.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 recruitment_loop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def recruitment_loop(request, debug_experiment):
    def recruitment_looper():
        timeout = request.config.getvalue("recruiter_timeout", 30)
        urls = set()
        while True:
Severity: Minor
Found in dallinger/pytest_dallinger.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 find_experiment_export has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def find_experiment_export(app_id):
    """Attempt to find a zipped export of an experiment with the ID provided
    and return its path. Returns None if not found.

    Search order:
Severity: Minor
Found in dallinger/data.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 regenerateDisplay has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function regenerateDisplay (state) {
  // Display parameters
  width = 600;
  height = 400;
  numDots = 80;
Severity: Minor
Found in demos/dlgr/demos/rogers/static/scripts/experiment.js - 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 node_neighbors has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def node_neighbors(node_id):
    """Send a GET request to the node table.

    This calls the neighbours method of the node
    making the request and returns a list of descriptions of
Severity: Minor
Found in dallinger/experiment_server/experiment_server.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 get_all_mapped_classes has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def get_all_mapped_classes():
    """
    Lists the different classes that are mapped with SQLAlchemy.
    Classes are only included if they have at least one row in the database.
    Returns a dictionary, keyed by class names,
Severity: Minor
Found in dallinger/db.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 recruiters has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def recruiters(self, n=1):
        """Iterator that provides recruiters along with the participant
        count to be recruited for up to `n` participants.

        We use the `Recruitment` table in the db to keep track of
Severity: Minor
Found in dallinger/recruiters.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 ensure_constraints_file_presence has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def ensure_constraints_file_presence(directory: str):
    """Looks into the path represented by the string `directory`.
    Does nothing if a `constraints.txt` file exists there and is
    newer than a sibling `requirements.txt` file.
    If it exists but is not up to date a ValueError exception is raised.
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 notify_duration_exceeded has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def notify_duration_exceeded(self, participants, reference_time):
        """The participant has exceed the maximum time for the activity,
        defined in the "duration" config value. We need find out the assignment
        status on MTurk and act based on this.
        """
Severity: Minor
Found in dallinger/recruiters.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 10 (exceeds 5 allowed). Consider refactoring.
Open

    def transmissions(self, status="all", failed=False):
        """Get transmissions in the network.

        status { "all", "received", "pending" }
        failed { False, True, "all" }
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 get has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def get(self, key, default=marker):
        # For now this is limited to "auto_recruit", but in the future it can be extended
        # to other parameters as well
        if key == "auto_recruit":
            from dallinger.db import redis_conn
Severity: Minor
Found in dallinger/config.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 start has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def start(self):
        self.copy_docker_compose_files()
        build_image(self.tmp_dir, self.experiment_name, self.out, self.needs_chrome)
        check_output("docker compose up -d".split())
        # Wait for postgres to complete initialization
Severity: Minor
Found in dallinger/docker/tools.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 error has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  dlgr.error = function (rejection) {
    // Render an error form for a rejected deferred returned by an ajax() call.
    var hit_params = {
          'recruiter': dlgr.identity.recruiter,
          'mode': dlgr.identity.mode,
Severity: Minor
Found in dallinger/frontend/static/scripts/dallinger2.js - About 1 hr to fix

Function addTile has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

HTMLActuator.prototype.addTile = function (tile) {
  var self = this;

  var wrapper   = document.createElement("div");
  var inner     = document.createElement("div");
Severity: Minor
Found in demos/dlgr/demos/twentyfortyeight/static/scripts/html_actuator.js - About 1 hr to fix

Function mousedownEventListener has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function mousedownEventListener(event) {
  if (clicked === false) {
    yNow = Math.round(stimulusYSize / PPU);

    // Training phase
Severity: Minor
Found in demos/dlgr/demos/function_learning/static/scripts/experiment.js - About 1 hr to fix
Severity
Category
Status
Source
Language