berkeley-cocosci/Wallace

View on GitHub

Showing 222 of 222 total issues

File models.py has 1315 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Define Wallace's core models."""

from datetime import datetime

from .db import Base
Severity: Major
Found in wallace/models.py - About 3 days to fix

    Function test_run_rogers has a Cognitive Complexity of 128 (exceeds 5 allowed). Consider refactoring.
    Open

            def test_run_rogers(self):
    
                """
                SIMULATE ROGERS
                """
    Severity: Minor
    Found in examples/rogers/tests/tests.py - About 2 days 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 custom.py has 947 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """Import custom routes into the experiment server."""
    
    from flask import (
        Blueprint,
        request,
    Severity: Major
    Found in wallace/custom.py - About 2 days to fix

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

      submit_responses = function() {
          if (lock===false) {
              lock=true;
              reqwest({
                  url: "/question/" + participant_id,
      Severity: Major
      Found in examples/chatroom/static/scripts/questionnaire.js and 3 other locations - About 1 day to fix
      examples/bartlett1932/static/scripts/questionnaire.js on lines 3..45
      examples/mcmcp/static/scripts/questionnaire.js on lines 3..45
      examples/rogers/static/scripts/questionnaire.js on lines 3..45

      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 315.

      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

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

      submit_responses = function() {
          if (lock===false) {
              lock=true;
              reqwest({
                  url: "/question/" + participant_id,
      Severity: Major
      Found in examples/bartlett1932/static/scripts/questionnaire.js and 3 other locations - About 1 day to fix
      examples/chatroom/static/scripts/questionnaire.js on lines 3..45
      examples/mcmcp/static/scripts/questionnaire.js on lines 3..45
      examples/rogers/static/scripts/questionnaire.js on lines 3..45

      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 315.

      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

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

      submit_responses = function() {
          if (lock===false) {
              lock=true;
              reqwest({
                  url: "/question/" + participant_id,
      Severity: Major
      Found in examples/mcmcp/static/scripts/questionnaire.js and 3 other locations - About 1 day to fix
      examples/bartlett1932/static/scripts/questionnaire.js on lines 3..45
      examples/chatroom/static/scripts/questionnaire.js on lines 3..45
      examples/rogers/static/scripts/questionnaire.js on lines 3..45

      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 315.

      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

      Identical blocks of code found in 4 locations. Consider refactoring.
      Open

      submit_responses = function() {
          if (lock===false) {
              lock=true;
              reqwest({
                  url: "/question/" + participant_id,
      Severity: Major
      Found in examples/rogers/static/scripts/questionnaire.js and 3 other locations - About 1 day to fix
      examples/bartlett1932/static/scripts/questionnaire.js on lines 3..45
      examples/chatroom/static/scripts/questionnaire.js on lines 3..45
      examples/mcmcp/static/scripts/questionnaire.js on lines 3..45

      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 315.

      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

      File command_line.py has 668 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      #!/usr/bin/python
      # -*- coding: utf-8 -*-
      
      """The Wallace command-line utility."""
      
      
      Severity: Major
      Found in wallace/command_line.py - About 1 day to fix

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

                        if whimsical:
                            msg = MIMEText(
                                """Dearest Friend,\n\nI am afraid I write to you with most
         grave tidings. At {}, during a routine check of the usually most delightful
         participant data table, I happened to notice that assignment {} has been
        Severity: Major
        Found in wallace/heroku/clock.py and 1 other location - About 1 day to fix
        wallace/heroku/clock.py on lines 111..148

        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 123.

        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

                        if whimsical:
                            msg = MIMEText(
                                """Dearest Friend,\n\nI am writing to let you know that at
         {}, during my regular (and thoroughly enjoyable) perousal of the most charming
          participant data table, I happened to notice that assignment {} has been
        Severity: Major
        Found in wallace/heroku/clock.py and 1 other location - About 1 day to fix
        wallace/heroku/clock.py on lines 182..232

        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 123.

        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

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

        try:
            exp = imp.load_source('experiment', "wallace_experiment.py")
            classes = inspect.getmembers(exp, inspect.isclass)
            exps = [c for c in classes
                    if (c[1].__bases__[0].__name__ in "Experiment")]
        Severity: Major
        Found in wallace/custom.py and 1 other location - About 7 hrs to fix
        wallace/heroku/clock.py on lines 21..31

        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 115.

        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

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

        try:
            exp = imp.load_source('experiment', "wallace_experiment.py")
            classes = inspect.getmembers(exp, inspect.isclass)
            exps = [c for c in classes
                    if (c[1].__bases__[0].__name__ in "Experiment")]
        Severity: Major
        Found in wallace/heroku/clock.py and 1 other location - About 7 hrs to fix
        wallace/custom.py on lines 73..83

        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 115.

        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 infos(self, type=None, failed=False):
                """
                Get infos in the network.
        
                type specifies the type of info (defaults to Info). failed { False,
        Severity: Major
        Found in wallace/models.py and 1 other location - About 6 hrs to fix
        wallace/models.py on lines 478..499

        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 108.

        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 transformations(self, type=None, failed=False):
                """Get transformations in the network.
        
                type specifies the type of transformation (default = Transformation).
                failed = { False, True, "all" }
        Severity: Major
        Found in wallace/models.py and 1 other location - About 6 hrs to fix
        wallace/models.py on lines 420..441

        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 108.

        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 worker_function has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring.
        Open

        def worker_function(event_type, assignment_id, participant_id):
            """Process the notification."""
            db.logger.debug("rq: worker_function working on job id: %s",
                            get_current_job().id)
            db.logger.debug('rq: Received Queue Length: %d (%s)', len(q),
        Severity: Minor
        Found in wallace/custom.py - About 6 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

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

        @wallace.command()
        @click.option('--verbose', is_flag=True, flag_value=True, help='Verbose mode')
        @click.option('--app', default=None, help='ID of the deployed experiment')
        def deploy(verbose, app):
            """Deploy app using Heroku to MTurk."""
        Severity: Major
        Found in wallace/command_line.py and 1 other location - About 6 hrs to fix
        wallace/command_line.py on lines 490..507

        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 106.

        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

                if direction == "from":
                    incoming_vectors = Vector.query.with_entities(Vector.origin_id)\
                        .filter_by(destination_id=self.id, failed=False).all()
        
                    neighbor_ids = [v.origin_id for v in incoming_vectors]
        Severity: Major
        Found in wallace/models.py and 1 other location - About 6 hrs to fix
        wallace/models.py on lines 740..748

        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 106.

        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

        @wallace.command()
        @click.option('--verbose', is_flag=True, flag_value=True, help='Verbose mode')
        @click.option('--app', default=None, help='ID of the sandboxed experiment')
        def sandbox(verbose, app):
            """Deploy app using Heroku to the MTurk Sandbox."""
        Severity: Major
        Found in wallace/command_line.py and 1 other location - About 6 hrs to fix
        wallace/command_line.py on lines 510..527

        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 106.

        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

                if direction == "to":
                    outgoing_vectors = Vector.query\
                        .with_entities(Vector.destination_id)\
                        .filter_by(origin_id=self.id, failed=False).all()
        
        
        Severity: Major
        Found in wallace/models.py and 1 other location - About 6 hrs to fix
        wallace/models.py on lines 750..757

        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 106.

        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

        create_agent = function() {
            reqwest({
                url: "/node/" + participant_id,
                method: 'post',
                type: 'json',
        Severity: Major
        Found in examples/mcmcp/static/scripts/experiment.js and 1 other location - About 6 hrs to fix
        examples/bartlett1932/static/scripts/experiment.js on lines 2..22

        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 166.

        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

        Severity
        Category
        Status
        Source
        Language