scitran/core

View on GitHub

Showing 294 of 518 total issues

Function finalize has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def finalize(self):

        paths = os.listdir(self.folder)
        total = len(paths)

Severity: Minor
Found in api/placer.py - About 1 hr to fix

    Function objWalk has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    module.exports = function objWalk(obj, callback, path, state) {
        var i, idx;
        state = state || {};
    
        if( path ) {
    Severity: Minor
    Found in swagger/support/walk.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 get_jobs has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_jobs(self, cid):
            # Only enabled for sessions container type per url rule in api.py
            self.config = self.container_handler_configurations["sessions"]
            self.storage = self.config['storage']
            cont = self._get_container(cid, projection={'files': 0, 'metadata': 0}, get_children=True)
    Severity: Minor
    Found in api/handlers/containerhandler.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 key_check has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def key_check(schema_url):
        """
        for sublists of mongo container there is no automatic key check when creating, updating or deleting an object.
        We are adding a custom array field to the json schemas ("key_fields").
        The uniqueness is checked on the combination of all the elements of "key_fields".
    Severity: Minor
    Found in api/validators.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 upgrade_to_24 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def upgrade_to_24():
        """
        scitran/core issue #720
    
        Migrate gear rules to the project level
    Severity: Minor
    Found in bin/database.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 recalc_session_compliance has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def recalc_session_compliance(self, session_id, session=None, template=None, hard=False):
            """
            Calculates a session's compliance with the project's session template.
            Returns True if the status changed, False otherwise
            """
    Severity: Minor
    Found in api/dao/containerstorage.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 draft4ToOpenApi2 has 43 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    SchemaTranspiler.prototype.draft4ToOpenApi2 = function(schema, defs, id) {
        var ref, defname;
    
        // Drop the $schema property, and make a copy
        schema = _.omit(schema, OMITTED_PROPERTIES);
    Severity: Minor
    Found in swagger/support/schema-transpiler.js - About 1 hr to fix

      Function simplifySchema has 42 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          function simplifySchema(schema, path, context) {
              schema = _.cloneDeep(schema);
              // If an x-sdk-schema is specified, use that
              if( schema['x-sdk-schema'] ) {
                  schema = schema['x-sdk-schema'];
      Severity: Minor
      Found in swagger/support/tasks/simplify-swagger.js - About 1 hr to fix

        Function list_permission_checker has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def list_permission_checker(handler, uid=None):
            def g(exec_op):
                def f(method, query=None, projection=None):
                    if uid is not None:
                        if uid != handler.uid and not handler.superuser_request and not handler.user_is_admin:
        Severity: Minor
        Found in api/auth/groupauth.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_html_generator has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_html_generator(_id):
                log = config.db.job_logs.find_one({'_id': _id})
        
                if log is None:
                    yield '<span class="fd--1">No logs were found for this job.</span>'
        Severity: Minor
        Found in api/jobs/jobs.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 container_has_original_data has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

        def container_has_original_data(container, child_cont_name=None):
            """
            Given a container, creates a list of all origin types
            for all files in the container and it's children, if provided.
            If the set only includes user and job uploaded files, the container
        Severity: Minor
        Found in api/dao/containerutil.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_el has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_all_el(self, query, user, projection, fill_defaults=False):
                if query is None:
                    query = {}
                if user:
                    if query.get('permissions'):
        Severity: Minor
        Found in api/dao/containerstorage.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 resolveRefs has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        Schemas.prototype.resolveRefs = function(relpath, obj, jsonpath) {
            var $ref, parts, curpath, actualpath, pathpart;
            // Ignore examples
            if( jsonpath && jsonpath[jsonpath.length-1] === 'example' ) {
                return obj;
        Severity: Minor
        Found in swagger/support/schemas.js - About 1 hr to fix

          Function exec_op has 12 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def exec_op(self, action, _id=None, payload=None, query=None, user=None,
          Severity: Major
          Found in api/dao/basecontainerstorage.py - About 1 hr to fix

            Function mergeModels has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                function mergeModels(root, context) {
                    var defs = root.definitions||{};
                    var keys = _.keys(defs);
                    var models = {};
                    var aliases = {};
            Severity: Minor
            Found in swagger/support/tasks/simplify-swagger.js - About 1 hr to fix

              Function _process_demo_results has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def _process_demo_results(self, results, grid):
                      """
                      Given demographics aggregation results, fill in base demographics grid
              
                      All `null` or unlisted values will be counted as 'Unknown or Not Reported'
              Severity: Minor
              Found in api/handlers/reporthandler.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_job has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def start_job(tags=None, peek=False):
                      """
                      Atomically change a 'pending' job to 'running' and returns it. Updates timestamp.
                      Will return None if there are no jobs to offer. Searches for jobs in FIFO order.
              
              
              Severity: Minor
              Found in api/jobs/queue.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 collection_permissions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def collection_permissions(handler, container=None, _=None):
                  """
                  Collections don't have a parent_container, catch param from generic call with _.
                  Permissions are checked on the collection itself or not at all if the collection is new.
                  """
              Severity: Minor
              Found in api/auth/containerauth.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 run has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

              def run(batch_job):
                  """
                  Creates jobs from proposed inputs, returns jobs enqueued.
                  """
              
              
              Severity: Minor
              Found in api/jobs/batch.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 suggest has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
              Open

                  def suggest(self, _id, cont_name, cid):
                      """
                      Given a container reference, return display information about parents, children and files
                      as well as information about which best match each gear input
              
              
              Severity: Minor
              Found in api/jobs/handlers.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

              Severity
              Category
              Status
              Source
              Language