coecms/ARCCSSive

View on GitHub

Showing 61 of 61 total issues

Function assign_constraints has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

def assign_constraints():
    ''' Assign default values and input to constraints '''
    kwargs = parse_input()
    admin = kwargs.pop("admin")
    searchargs={}
Severity: Minor
Found in ARCCSSive/cli/compare_ESGF.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

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

if __name__ == '__main__':
    # check python version and then call main()
    if sys.version_info < ( 2, 7):
        # python too old, kill the script
        sys.exit("This script requires Python 2.7 or newer!")
Severity: Major
Found in ARCCSSive/cli/compare_ESGF.py and 1 other location - About 1 hr to fix
ARCCSSive/cli/search_replica.py on lines 120..126

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

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

                    user_date="_".join([os.environ['USER'],datetime.now().strftime("%Y%m%dT%H%M")+".txt"])
Severity: Major
Found in ARCCSSive/cli/compare_ESGF.py and 1 other location - About 1 hr to fix
ARCCSSive/cli/compare_ESGF.py on lines 169..169

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

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

                    user_date="_".join([os.environ['USER'],datetime.now().strftime("%Y%m%dT%H%M")+".txt"])
Severity: Major
Found in ARCCSSive/cli/compare_ESGF.py and 1 other location - About 1 hr to fix
ARCCSSive/cli/compare_ESGF.py on lines 182..182

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

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

def assign_constraints():
    ''' Assign default values and input to constraints '''
    kwargs = parse_input()
    admin = kwargs.pop("admin")
    warning = kwargs.pop("warning")[0]
Severity: Minor
Found in database_updates/add_warning.py - About 55 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

                    for s in upd_urls:
                        print(s.split("'")[0])
                        fout.writelines("'" +s + "'\n")
                    fout.close()
Severity: Major
Found in ARCCSSive/cli/compare_ESGF.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if request2: os.system ("cp %s %s" % (outfile, outdir+outfile)) 
            for var in variables:
    Severity: Major
    Found in ARCCSSive/cli/compare_ESGF.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                      for f in files:
                          checksum=check_hash(v_obj.path+"/"+f,'md5')
                          rows.append(dict(filename=f, md5=checksum, version_id=v_obj.id))
                          add_bulk_items(db, VersionFile, rows)
                  else:
      Severity: Major
      Found in database_updates/upload_drstree.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if ctype=="None": 
                                urls.append("' '".join([f.filename,f.download_url,"None","None"]))
                                dataset_info.append(",".join([f.filename,f.tracking_id,"None"])+"\n")
                            else:
                                urls.append("' '".join([f.filename,f.download_url,ctype.upper(),f.checksum]))
        Severity: Major
        Found in ARCCSSive/CMIP5/compare_helpers.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              for s in urls:
                                  print(s.split("'")[0])
                                  fout.writelines("'" +s + "'\n")
                              fout.close()
          Severity: Major
          Found in ARCCSSive/cli/compare_ESGF.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                            for f in files:
                                kw_files['filename']=f
                                kw_files['md5']=check_hash(v_obj.path+"/"+f,'md5')
                                insert_unique(db, VersionFile, **kw_files)
            
            
            Severity: Major
            Found in database_updates/upload_drstree.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                  if not admin:
                                      ds_info=[str(x) for x in ds_instance.items()]
                                      write_log(" ".join(["update"]+ds_info+[v.version,v.path,"\n"]))
                          # if local dataset_id is the same as remote skip all other checks
                          if v.dataset_id==ds['dataset_id']:
              Severity: Major
              Found in ARCCSSive/CMIP5/compare_helpers.py - About 45 mins to fix

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

                def write_table(matrix,exp):
                    ''' write a csv table to summarise search
                        argument matrix:
                        argument exp: 
                    '''
                Severity: Minor
                Found in ARCCSSive/CMIP5/compare_helpers.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 f.filename not in different: continue
                                    if ctype=="None": 
                Severity: Major
                Found in ARCCSSive/CMIP5/compare_helpers.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                  for v in db_results:
                                      insert_unique( db, VersionWarning, **{'version_id':v.id, 'warning':warning, 
                                                   'added_by':email, 'added_on':datetime.now().strftime("%Y%m%d")} )
                  Severity: Major
                  Found in database_updates/add_warning.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        for line in up_dataset_info:
                                            ds_info.write(line)
                                        ds_info.close()
                    Severity: Major
                    Found in ARCCSSive/cli/compare_ESGF.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                          if warnings and v.warnings != []:
                                              fout.write("Warnings:\n")
                                              for w in v.warnings:
                                                  fout.write(w.warning + "\n added by " + w.added_by + " on the " + w.added_on + "\n")
                              if not someresult:
                      Severity: Major
                      Found in ARCCSSive/cli/search_replica.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                            for line in dataset_info:
                                                ds_info.write(line)
                                            ds_info.close()
                        Severity: Major
                        Found in ARCCSSive/cli/compare_ESGF.py - About 45 mins to fix

                          Function result_matrix has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                          def result_matrix(matrix,exp,var,remote,local):
                          Severity: Minor
                          Found in ARCCSSive/CMIP5/compare_helpers.py - About 35 mins to fix

                            Function compare_instances has 5 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                            def compare_instances(db,remote,local,const_keys,admin):
                            Severity: Minor
                            Found in ARCCSSive/CMIP5/compare_helpers.py - About 35 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language