scitran/core

View on GitHub

Showing 518 of 518 total issues

Function get_all has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    def get_all(self, cont_name, par_cont_name=None, par_id=None):
        self.config = self.container_handler_configurations[cont_name]
        self.storage = self.config['storage']

        projection = self.config['list_projection'].copy()
Severity: Minor
Found in api/handlers/containerhandler.py - About 3 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 get_all_el has a Cognitive Complexity of 23 (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/basecontainerstorage.py - About 3 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

db = pymongo.MongoClient(
    __config['persistent']['db_uri'],
    j=True, # Requests only return once write has hit the DB journal
    connectTimeoutMS=__config['persistent']['db_connect_timeout'],
    serverSelectionTimeoutMS=__config['persistent']['db_server_selection_timeout'],
Severity: Major
Found in api/config.py and 1 other location - About 3 hrs to fix
api/config.py on lines 121..125

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

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

log_db = pymongo.MongoClient(
    __config['persistent']['db_log_uri'],
    j=True, # Requests only return once write has hit the DB journal
    connectTimeoutMS=__config['persistent']['db_connect_timeout'],
    serverSelectionTimeoutMS=__config['persistent']['db_server_selection_timeout'],
Severity: Major
Found in api/config.py and 1 other location - About 3 hrs to fix
api/config.py on lines 112..116

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

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 exports has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(grunt) {
    var _ = require('lodash');
    var path = require('path');
    var fs = require('fs');
    var yaml = require('js-yaml');
Severity: Major
Found in swagger/support/tasks/print-doc-coverage.js - About 3 hrs to fix

    File basecontainerstorage.py has 297 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import copy
    import bson
    import datetime
    import pymongo.errors
    
    
    Severity: Minor
    Found in api/dao/basecontainerstorage.py - About 3 hrs to fix

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

              if user:
                  if query.get('permissions'):
                      query['$and'] = [{'permissions': {'$elemMatch': user}}, {'permissions': query.pop('permissions')}]
                  else:
                      query['permissions'] = {'$elemMatch': user}
      Severity: Major
      Found in api/dao/containerstorage.py and 1 other location - About 3 hrs to fix
      api/dao/basecontainerstorage.py on lines 292..296

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

      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

              if user:
                  if query.get('permissions'):
                      query['$and'] = [{'permissions': {'$elemMatch': user}}, {'permissions': query.pop('permissions')}]
                  else:
                      query['permissions'] = {'$elemMatch': user}
      Severity: Major
      Found in api/dao/basecontainerstorage.py and 1 other location - About 3 hrs to fix
      api/dao/containerstorage.py on lines 137..141

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

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

      def find_matching_conts(gear, containers, container_type):
          """
          Give a gear and a list of containers, find files that:
            - have no solution to the gear's input schema (not matched)
            - have multiple solutions to the gear's input schema (ambiguous)
      Severity: Minor
      Found in api/jobs/batch.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 default has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

      def default(handler, user=None):
          def g(exec_op):
              def f(method, _id=None, query=None, payload=None, projection=None):
                  if handler.public_request:
                      handler.abort(403, 'public request is not authorized')
      Severity: Minor
      Found in api/auth/userauth.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 handle_origin has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
      Open

          def handle_origin(self, result):
              """
              Given an object with a `files` array key, coalesce and merge file origins if requested.
              """
      
      
      Severity: Minor
      Found in api/handlers/containerhandler.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

      File authproviders.py has 287 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import datetime
      import requests
      import json
      import urllib
      import urlparse
      Severity: Minor
      Found in api/auth/authproviders.py - About 2 hrs to fix

        Function enqueue_job has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def enqueue_job(job_map, origin, perm_check_uid=None):
                """
                Using a payload for a proposed job, creates and returns (but does not insert)
                a Job object. This preperation includes:
                  - confirms gear exists
        Severity: Minor
        Found in api/jobs/queue.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 summary has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def summary(self):
                """Return a summary of what has been/will be downloaded based on a given query"""
                res = {}
                req = self.request.json_body
                cont_query = {
        Severity: Minor
        Found in api/download.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

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

                if not update.get('$set'):
                    update['$set'] = {'modified': datetime.datetime.utcnow()}
                else:
                    update['$set']['modified'] = datetime.datetime.utcnow()
        Severity: Major
        Found in api/dao/liststorage.py and 1 other location - About 2 hrs to fix
        api/dao/basecontainerstorage.py on lines 373..376

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

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

        def process_upload(request, strategy, container_type=None, id_=None, origin=None, context=None, response=None, metadata=None):
            """
            Universal file upload entrypoint.
        
            Format:
        Severity: Minor
        Found in api/upload.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

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

                if not update.get('$set'):
                    update['$set'] = {'modified': datetime.datetime.utcnow()}
                else:
                    update['$set']['modified'] = datetime.datetime.utcnow()
        Severity: Major
        Found in api/dao/basecontainerstorage.py and 1 other location - About 2 hrs to fix
        api/dao/liststorage.py on lines 213..216

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

        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 exports has 67 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function(grunt) {
            var path = require('path');
            var fs = require('fs');
            var _ = require('lodash');
            var yaml = require('js-yaml');
        Severity: Major
        Found in swagger/support/tasks/validate-swagger.js - About 2 hrs to fix

          ContainerHandler has 24 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class ContainerHandler(base.RequestHandler):
              """
              This class handle operations on a generic container
          
              The pattern used is:
          Severity: Minor
          Found in api/handlers/containerhandler.py - About 2 hrs to fix

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

            def upgrade_to_33():
                """
                scitran/core issue #808 - make analyses use their own collection
                """
                for cont_name in ['projects', 'sessions', 'acquisitions', 'collections']:
            Severity: Major
            Found in bin/database.py and 1 other location - About 2 hrs to fix
            bin/database.py on lines 1354..1360

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

            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