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={}
- Read upRead up
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!")
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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"])
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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"])
- Read upRead up
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
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]
- Read upRead up
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()
Avoid deeply nested control flow statements. Open
if request2: os.system ("cp %s %s" % (outfile, outdir+outfile))
for var in variables:
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:
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]))
Avoid deeply nested control flow statements. Open
for s in urls:
print(s.split("'")[0])
fout.writelines("'" +s + "'\n")
fout.close()
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)
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']:
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:
'''
- Read upRead up
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":
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")} )
Avoid deeply nested control flow statements. Open
for line in up_dataset_info:
ds_info.write(line)
ds_info.close()
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:
Avoid deeply nested control flow statements. Open
for line in dataset_info:
ds_info.write(line)
ds_info.close()
Function result_matrix
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def result_matrix(matrix,exp,var,remote,local):
Function compare_instances
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def compare_instances(db,remote,local,const_keys,admin):