Dallinger/Dallinger

View on GitHub

Showing 1,036 of 1,036 total issues

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

def create_question(participant_id):
    """Send a POST request to the question table.

    Questions store information at the participant level, not the node
    level.
Severity: Minor
Found in dallinger/experiment_server/experiment_server.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 error_response has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def error_response(
Severity: Minor
Found in dallinger/experiment_server/utils.py - About 45 mins to fix

Function qualify has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def qualify(workers, qualification, value, by_name, notify, sandbox):
Severity: Minor
Found in dallinger/command_line/__init__.py - About 45 mins to fix

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

def user_log_dir(appname=None, appauthor=None, version=None, opinion=True):
    r"""Return full path to the user-specific log 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 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 handle_launch_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def handle_launch_data(url, error, delay=DEFAULT_DELAY, attempts=MAX_ATTEMPTS):
    """Sends a POST request to te given `url`, retrying it with exponential backoff.
    The passed `error` function is invoked to give feedback as each error occurs,
    possibly multiple times.
    """
Severity: Minor
Found in dallinger/deployment.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 _register_hit_type has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _register_hit_type(
Severity: Minor
Found in dallinger/mturk.py - About 45 mins to fix

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

def check_experiment_dependencies(requirements_file):
    """Verify that the dependencies defined in a requirements file are
    in fact installed.
    If the environment variable SKIP_DEPENDENCY_CHECK is set, no check
    will be performed.
Severity: Minor
Found in dallinger/utils.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 _assign_experiment_qualifications has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def _assign_experiment_qualifications(self, worker_id, qualifications):
        # Called from an async worker.
        by_name = {qual["name"]: qual for qual in qualifications}
        result = self._ensure_mturk_qualifications(qualifications)
        for qual in result["new_qualifications"]:
Severity: Minor
Found in dallinger/recruiters.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 open_recruitment has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def open_recruitment(self, n=1):
        """Return initial experiment URL list."""
        logger.info("Multi recruitment running for {} participants".format(n))
        recruitments = []
        messages = {}
Severity: Minor
Found in dallinger/recruiters.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 write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def write(self, filter_sensitive=False, directory=None):
        parser = configparser.ConfigParser()
        parser.add_section("Parameters")
        for layer in reversed(self.data):
            for k, v in layer.items():
Severity: Minor
Found in dallinger/config.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 setup_experiment has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

def setup_experiment(
Severity: Minor
Found in dallinger/utils.py - About 45 mins to fix

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

def get_base_url():
    """Returns the base url for the experiment.
    Looks into environment variable HOST first, then in the
    experiment config.
    If the URL is on Heroku makes sure the protocol is https.
Severity: Minor
Found in dallinger/utils.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

Avoid deeply nested control flow statements.
Open

                        for fn in filenames:
                            dst_fileparts = (
                                [dst, filename] + [os.path.relpath(dirpath, src)] + [fn]
                            )
                            dst_filepath = os.path.join(*dst_fileparts)
Severity: Major
Found in dallinger/utils.py - About 45 mins to fix

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def wait_for_element(driver, el_id, timeout=10):
    return WebDriverWait(driver, timeout).until(
        EC.presence_of_element_located((By.ID, el_id))
Severity: Minor
Found in dallinger/pytest_dallinger.py and 1 other location - About 45 mins to fix
dallinger/pytest_dallinger.py on lines 634..636

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 35.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

def wait_until_clickable(driver, el_id, timeout=10):
    return WebDriverWait(driver, timeout).until(
        EC.element_to_be_clickable((By.ID, el_id))
Severity: Minor
Found in dallinger/pytest_dallinger.py and 1 other location - About 45 mins to fix
dallinger/pytest_dallinger.py on lines 628..630

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 35.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function revoke has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def revoke(workers, qualification, by_name, reason, sandbox):
Severity: Minor
Found in dallinger/command_line/__init__.py - About 35 mins to fix

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

    def __init__(
Severity: Minor
Found in dallinger/command_line/appdirs.py - About 35 mins to fix

Function compensate_worker has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def compensate_worker(self, worker_id, email, dollars, notify=True):
Severity: Minor
Found in dallinger/recruiters.py - About 35 mins to fix

Function pull_table has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def pull_table(
Severity: Minor
Found in dallinger/experiment.py - About 35 mins to fix

Function debug has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

def debug(verbose, bot, proxy, no_browsers=False, exp_config=None):
Severity: Minor
Found in dallinger/command_line/docker.py - About 35 mins to fix
Severity
Category
Status
Source
Language