scitran/core

View on GitHub

Showing 294 of 518 total issues

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

    def validate_user(self, openid, registration_code=None):
        if registration_code:
            user = config.db.users.find_one({'wechat.registration_code': registration_code})
            if user is None:
                raise APIUnknownUserException('Invalid or expired registration link.')
Severity: Minor
Found in api/auth/authproviders.py - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

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

def upgrade_to_30_closure_analysis(coll_item, coll):
    analyses = coll_item.get('analyses', [])

    for analysis_ in analyses:
        files = analysis_.get('files', [])
Severity: Minor
Found in bin/database.py - About 45 mins to fix

Cognitive Complexity

Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

A method's cognitive complexity is based on a few simple rules:

  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
  • Code is considered more complex for each "break in the linear flow of the code"
  • Code is considered more complex when "flow breaking structures are nested"

Further reading

Avoid deeply nested control flow statements.
Open

                        if file_.get('measurements'):
                            file_['measurements'].append(measurement)
                        else:
                            file_['measurements'] = [measurement]
                    if info and file_.get('type', '') == 'dicom':
Severity: Major
Found in bin/database.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if code is None:
                                code = 'unknown_subject'
                                subject['code'] = code
                            subject_dict[code] = subject
    Severity: Major
    Found in api/download.py - About 45 mins to fix

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

          def set_origin(self, drone_request, job_context):
              """
              Add an origin to the request object. Used later in request handler logic.
      
              Pretty clear duplication of logic with superuser_request / drone_request;
      Severity: Minor
      Found in api/web/base.py - About 45 mins to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Avoid deeply nested control flow statements.
      Open

                              if measurement:
                                  f['measurements'] = [measurement]
                              if info:
      Severity: Major
      Found in api/placer.py - About 45 mins to fix

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

        def dispatcher(router, request, response):
            try:
                if uwsgi is not None:
                    uwsgi.set_logvar('request_id', request.id)
            except: # pylint: disable=bare-except
        Severity: Minor
        Found in api/web/start.py - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        def log_access(access_type, cont_kwarg='cont_name', cont_id_kwarg='cid', filename_kwarg='name'):
            """
            A decorator to log a user or drone's access to an endpoint
            """
            def log_access_decorator(handler_method):
        Severity: Minor
        Found in api/web/request.py - About 45 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

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

        def _upsert_container(cont, cont_type, parent, parent_type, upload_type, timestamp):
        Severity: Minor
        Found in api/dao/hierarchy.py - About 45 mins to fix

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

              def update_el(self, _id, payload, unset_payload=None, recursive=False, r_payload=None, replace_metadata=False):
          Severity: Minor
          Found in api/dao/basecontainerstorage.py - About 45 mins to fix

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

                def get_parent_tree(self, _id, cont=None, projection=None, add_self=False):
                    parents = []
            
                    curr_storage = self
            
            
            Severity: Minor
            Found in api/dao/basecontainerstorage.py - About 45 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

                def update_el(self, _id, payload, unset_payload=None, recursive=False, r_payload=None, replace_metadata=False):
            Severity: Minor
            Found in api/dao/containerstorage.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if file_:
                                      file_['input'] = True
                                      files.append(file_)
              
              
              Severity: Major
              Found in bin/database.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if modality:
                                            f['modality'] = modality
                
                
                Severity: Major
                Found in api/placer.py - About 45 mins to fix

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

                  def _find_or_create_destination_project(group_id, project_label, timestamp, user):
                      group_id, project_label = _group_id_fuzzy_match(group_id, project_label)
                      group = config.db.groups.find_one({'_id': group_id})
                  
                      if project_label == '':
                  Severity: Minor
                  Found in api/dao/hierarchy.py - About 45 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

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

                      def update_el(self, _id, payload, unset_payload=None, recursive=False, r_payload=None, replace_metadata=False):
                  Severity: Minor
                  Found in api/dao/containerstorage.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if info:
                                                f['info'] = info
                                            if modality:
                    Severity: Major
                    Found in api/placer.py - About 45 mins to fix

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

                          def update_el(self, _id, payload, unset_payload=None, recursive=False, r_payload=None, replace_metadata=False):
                      Severity: Minor
                      Found in api/dao/containerstorage.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                        for an in analyses:
                                            files = an.pop('files', [])
                                            doc = {
                                                'analysis':             an,
                                                'session':              s,
                        Severity: Major
                        Found in bin/dicom_doctype.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                                  if 'deleted' in f or not check_cont(f, fr_temp):
                                                      # Didn't find a match, on to the next one
                                                      continue
                                                  else:
                                                      count += 1
                          Severity: Major
                          Found in api/dao/hierarchy.py - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language