scitran/core

View on GitHub

Showing 518 of 518 total issues

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

            try:
                result = self._get_result(config.db.command('aggregate', 'sessions', pipeline=pipeline))
            except APIReportException:
                # Edge case when none of the subjects have a sex field
                result = {}
Severity: Minor
Found in api/handlers/reporthandler.py and 1 other location - About 50 mins to fix
api/handlers/reporthandler.py on lines 455..459

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

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 project.get('template'):
            payload['project_has_template'] = True
            payload['satisfies_template'] = hierarchy.is_session_compliant(payload, project.get('template'))
Severity: Minor
Found in api/dao/containerstorage.py and 1 other location - About 50 mins to fix
api/dao/containerstorage.py on lines 252..254

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

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 payload.get('subject') is not None and payload['subject'].get('info') is not None:
Severity: Minor
Found in api/dao/basecontainerstorage.py and 1 other location - About 50 mins to fix
api/handlers/containerhandler.py on lines 487..487

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

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

                acq_ids += [a['_id'] for a in config.db.acquisitions.find({'session': item_id, 'deleted': {'$exists': False}}, [])]
Severity: Minor
Found in api/handlers/collectionshandler.py and 1 other location - About 50 mins to fix
api/handlers/collectionshandler.py on lines 87..87

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

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 payload.get('subject') is not None and payload['subject'].get('_id') is not None:
Severity: Minor
Found in api/handlers/containerhandler.py and 1 other location - About 50 mins to fix
api/dao/basecontainerstorage.py on lines 241..241

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

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

    @property
    def update_validator(self):
        update_schema_uri = validators.schema_uri('input', self.update_payload_schema_file)
        update_validator = validators.from_schema_path(update_schema_uri)
        return update_validator
Severity: Minor
Found in api/handlers/refererhandler.py and 1 other location - About 50 mins to fix
api/handlers/refererhandler.py on lines 39..43

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

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

function validateTemplateArgs(tmplpath, template, args) {
    var i, param;
    if( !template || !template.parameters ) {
        return;
    }
Severity: Minor
Found in swagger/support/swagger-resolver.js - 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( this.defNames[k] ) {
                        errors.push(new LintError('Duplicate definition found: "' + k + '"', filename)); 
                    }
Severity: Major
Found in swagger/support/schema-lint.js - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if j.origin['type'] != 'user':
                                raise Exception('Cannot provide an API key to a job not launched by a user')
    
    
    Severity: Major
    Found in api/jobs/handlers.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if cached_gears.get(gear_id, None) is not None:
                                  gear_name = cached_gears[gear_id]
                              else:
                                  gear_id_bson = bson.ObjectId(gear_id)
                                  gear = config.db.gears.find_one({'_id': gear_id_bson})
      Severity: Major
      Found in api/handlers/containerhandler.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if y.get('_id') == self.uid:
                                    ok = True
                                    break
        
        
        Severity: Major
        Found in api/handlers/resolvehandler.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if not isinstance(cf[x], bool):
                                      r['target']['env']['FW_CONFIG_' + config_name] = str(cf[x])
                                  else:
                                      r['target']['env']['FW_CONFIG_' + config_name] = str(cf[x]).lower()
          
          
          Severity: Major
          Found in api/jobs/jobs.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                        if last > fileinfo['size']:
                                            length = fileinfo['size'] - first
                                        else:
                                            length = last - first + 1
            
            
            Severity: Major
            Found in api/handlers/listhandler.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if y.get('_id') == self.uid:
                                          ok = True
                                          break
                              else:
              Severity: Major
              Found in api/handlers/resolvehandler.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if v:
                                            null_filter['bool']['should'].append({'terms': {k+'.raw': v}})
                                        modified_filters.append(null_filter)
                Severity: Major
                Found in api/handlers/dataexplorerhandler.py - About 45 mins to fix

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

                  def get_rules_for_container(db, container):
                      """
                      Recursively walk the hierarchy until the project object is found.
                      """
                  
                  
                  Severity: Minor
                  Found in api/jobs/rules.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 get has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def get(self, cont_name, **kwargs):
                          _id = kwargs.get('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 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 isinstance(v, list):
                                              v.remove("null")
                                          elif isinstance(v, str):
                                              v = None
                                          null_filter = {
                  Severity: Major
                  Found in api/handlers/dataexplorerhandler.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if not ticket.get('logged', False):
                                                self.log_user_access(AccessType.download_file, cont_name=cont_name, cont_id=cid, filename=fileinfo['name'])
                                                config.db.downloads.update_one({'_id': ticket_id}, {'$set': {'logged': True}})
                                        else:
                    Severity: Major
                    Found in api/handlers/refererhandler.py - About 45 mins to fix

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

                          def _initialize_request(self, cont_name, list_name, _id, query_params=None):
                              """
                              This method loads:
                              1) the container that will be modified
                              2) the storage class that will handle the database actions
                      Severity: Minor
                      Found in api/handlers/listhandler.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

                      Severity
                      Category
                      Status
                      Source
                      Language