scitran/core

View on GitHub

Showing 294 of 518 total issues

Function files_sublist has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def files_sublist(handler, container):
    """
    Files have slightly modified permissions centered around origin.
    Admin is required to remove files with an origin type other than engine or user.
    """
Severity: Minor
Found in api/auth/listauth.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_exception has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def handle_exception(self, exception, debug, return_json=False): # pylint: disable=arguments-differ
        """
        Send JSON response for exception

        For HTTP and other known exceptions, use its error code
Severity: Minor
Found in api/web/base.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 modify_info has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def modify_info(self, _id, query_params, payload):
        update = {}
        set_payload = payload.get('set')
        delete_payload = payload.get('delete')
        replace_payload = payload.get('replace')
Severity: Minor
Found in api/dao/liststorage.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

Consider simplifying this complex logical expression.
Open

            if handler.public_request:
                handler.abort(403, 'public request is not authorized')
            elif handler.superuser_request and not (method == 'DELETE' and _id == handler.uid):
                pass
            elif handler.user_is_admin and (method == 'DELETE' and not _id == handler.uid):
Severity: Critical
Found in api/auth/userauth.py - About 2 hrs to fix

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

        def __init__(self, gear_id, inputs, destination=None, tags=None,
    Severity: Major
    Found in api/jobs/jobs.py - About 2 hrs to fix

      Function create_potential_jobs has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def create_potential_jobs(db, container, container_type, file_):
          """
          Check all rules that apply to this file, and creates the jobs that should be run.
          Jobs are created but not enqueued.
          Returns list of potential job objects containing job ready to be inserted and rule.
      Severity: Minor
      Found in api/jobs/rules.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 apply_env_variables has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def apply_env_variables(config):
          # Overwrite default config values with SCITRAN env variables if available
      
          # Load auth config from file if available
          if 'SCITRAN_AUTH_CONFIG_FILE' in os.environ:
      Severity: Minor
      Found in api/config.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 create_el has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

          def create_el(self, analysis, parent_type, parent_id, origin, uid=None):
              """
              Create an analysis.
              * Fill defaults if not provided
              * Flatten input filerefs using `FileReference.get_file()`
      Severity: Minor
      Found in api/dao/containerstorage.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 get_parent_tree has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def get_parent_tree(cont_name, _id):
          """
          Given a contanier and an id, returns that container and its parent tree.
      
          For example, given `sessions`, `<session_id>`, it will return:
      Severity: Minor
      Found in api/dao/hierarchy.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 util.py has 260 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import datetime
      import enum as baseEnum
      import errno
      import hashlib
      import json
      Severity: Minor
      Found in api/util.py - About 2 hrs to fix

        Function process_file_field has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def process_file_field(self, field, file_attrs):
                # Only create the hierarchy once
                if self.count == 0:
                    # If not a superuser request, pass uid of user making the upload request
                    targets = self.create_hierarchy(self.metadata, type_=self.match_type, user=self.context.get('uid'))
        Severity: Minor
        Found in api/placer.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 parse_range_header has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def parse_range_header(range_header_val, valid_units=('bytes',)):
            """
            Range header parser according to RFC7233
        
            https://tools.ietf.org/html/rfc7233
        Severity: Minor
        Found in api/util.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 create_or_recreate_ttl_index has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

        def create_or_recreate_ttl_index(coll_name, index_name, ttl):
            if coll_name in db.collection_names():
                index_list = db[coll_name].index_information()
                if index_list:
                    for index in index_list:
        Severity: Minor
        Found in api/config.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 recalc_sessions_compliance has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def recalc_sessions_compliance(self, project_id=None):
                if project_id is None:
                    # Recalc all projects
                    projects = self.get_all_el({'template': {'$exists': True}}, None, None)
                else:
        Severity: Minor
        Found in api/dao/containerstorage.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 finalize has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
        Open

            def finalize(self):
                job = None
                job_ticket = None
                success = True
        
        
        Severity: Minor
        Found in api/placer.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 containerutil.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import bson.objectid
        import copy
        
        from .. import config
        from ..auth import has_access
        Severity: Minor
        Found in api/dao/containerutil.py - About 2 hrs to fix

          Function _lintDuplicateNames has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          SchemaLinter.prototype._lintDuplicateNames = function(schema, filename) {
              var k, errors = [];
          
              if( schema.definitions ) {
                  for( k in schema.definitions ) {
          Severity: Minor
          Found in swagger/support/schema-lint.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 _lintDefinitionNameStyle has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          SchemaLinter.prototype._lintDefinitionNameStyle = function(schema, filename) {
              var k, errors = [];
          
              if( schema.definitions ) {
                  for( k in schema.definitions ) {
          Severity: Minor
          Found in swagger/support/schema-lint.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 put has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

              def put(self, cont_name, **kwargs):
                  _id = kwargs.pop('cid')
                  self.config = self.container_handler_configurations[cont_name]
                  self.storage = self.config['storage']
                  container = self._get_container(_id)
          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 upgrade_to_12 has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          def upgrade_to_12():
              """
              scitran/core PR #372
          
              Store job inputs on job-based analyses
          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

          Severity
          Category
          Status
          Source
          Language