scitran/core

View on GitHub

Showing 518 of 518 total issues

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

    def log_user_access(self, access_type, cont_name=None, cont_id=None, filename=None, multifile=False, origin_override=None):
Severity: Minor
Found in api/web/base.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 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 '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

          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

              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

              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

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

                    if obj.get('created'):
                        obj['created'] = dateutil.parser.parse(obj['created'])
                Severity: Major
                Found in bin/oneoffs/load_external_data.py and 8 other locations - About 45 mins to fix
                api/dao/hierarchy.py on lines 512..513
                api/dao/hierarchy.py on lines 531..532
                api/handlers/containerhandler.py on lines 436..437
                api/handlers/containerhandler.py on lines 484..485
                api/handlers/listhandler.py on lines 282..283
                api/handlers/listhandler.py on lines 298..299
                bin/oneoffs/load_external_data.py on lines 32..33
                bin/oneoffs/load_external_data.py on lines 36..37

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

                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 not filename:
                                filename = arc_prefix + '_' + datetime.datetime.utcnow().strftime('%Y%m%d_%H%M%S') + '.tar'
                Severity: Minor
                Found in api/download.py and 1 other location - About 45 mins to fix
                api/download.py on lines 107..107

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

                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

                        acquisition = config.db.acquisitions.find_one_and_update(
                            query, {
                                '$set': updates,
                                '$setOnInsert': insert_map
                            },
                Severity: Minor
                Found in api/placer.py and 1 other location - About 45 mins to fix
                api/placer.py on lines 628..634

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

                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

                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/basecontainerstorage.py - About 45 mins to fix

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

                            if payload.get('timestamp'):
                                payload['timestamp'] = dateutil.parser.parse(payload['timestamp'])
                    Severity: Major
                    Found in api/handlers/containerhandler.py and 8 other locations - About 45 mins to fix
                    api/dao/hierarchy.py on lines 512..513
                    api/dao/hierarchy.py on lines 531..532
                    api/handlers/containerhandler.py on lines 484..485
                    api/handlers/listhandler.py on lines 282..283
                    api/handlers/listhandler.py on lines 298..299
                    bin/oneoffs/load_external_data.py on lines 32..33
                    bin/oneoffs/load_external_data.py on lines 34..35
                    bin/oneoffs/load_external_data.py on lines 36..37

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

                    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 9 locations. Consider refactoring.
                    Open

                        if obj.get('modified'):
                            obj['modified'] = dateutil.parser.parse(obj['modified'])
                    Severity: Major
                    Found in bin/oneoffs/load_external_data.py and 8 other locations - About 45 mins to fix
                    api/dao/hierarchy.py on lines 512..513
                    api/dao/hierarchy.py on lines 531..532
                    api/handlers/containerhandler.py on lines 436..437
                    api/handlers/containerhandler.py on lines 484..485
                    api/handlers/listhandler.py on lines 282..283
                    api/handlers/listhandler.py on lines 298..299
                    bin/oneoffs/load_external_data.py on lines 32..33
                    bin/oneoffs/load_external_data.py on lines 34..35

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

                    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 'timestamp' in insert_map:
                                insert_map['timestamp'] = dateutil.parser.parse(insert_map['timestamp'])
                    Severity: Minor
                    Found in api/placer.py and 1 other location - About 45 mins to fix
                    api/placer.py on lines 625..626

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

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

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

                      def handle_files(parent, parent_type, files, dicom_mappings, permissions, doc):
                      Severity: Minor
                      Found in bin/dicom_doctype.py - About 45 mins to fix

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

                            if obj.get('timestamp'):
                                obj['timestamp'] = dateutil.parser.parse(obj['timestamp'])
                        Severity: Major
                        Found in bin/oneoffs/load_external_data.py and 8 other locations - About 45 mins to fix
                        api/dao/hierarchy.py on lines 512..513
                        api/dao/hierarchy.py on lines 531..532
                        api/handlers/containerhandler.py on lines 436..437
                        api/handlers/containerhandler.py on lines 484..485
                        api/handlers/listhandler.py on lines 282..283
                        api/handlers/listhandler.py on lines 298..299
                        bin/oneoffs/load_external_data.py on lines 34..35
                        bin/oneoffs/load_external_data.py on lines 36..37

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

                        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

                        Avoid deeply nested control flow statements.
                        Open

                                            if index_list[index].get('expireAfterSeconds', None) != ttl:
                                                # drop existing, recreate below
                                                db[coll_name].drop_index(index)
                                                break
                                            else:
                        Severity: Major
                        Found in api/config.py - About 45 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language