Skip to content

Commit a159d60

Browse files
committed
Linting and reformating done
1 parent 5f99da8 commit a159d60

File tree

1 file changed

+23
-16
lines changed

1 file changed

+23
-16
lines changed

slither/analyses/data_dependency/data_dependency.py

+23-16
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,22 @@ def get_all_dependencies_ssa(
292292
return context.context[KEY_SSA_UNPROTECTED]
293293
return context.context[KEY_SSA]
294294

295+
295296
def get_must_depends_on(x):
296297
must_dependencies = compute_must_dependencies(x)
297298
if len(must_dependencies) > 1 or len(must_dependencies) == 0:
298299
return None
299300
return list(must_dependencies)[0]
300301

302+
301303
def compute_must_dependencies(x):
302-
if isinstance(x, SolidityVariableComposed) or isinstance(x, Constant) or \
303-
(x.function.visibility in ['public', 'external'] and x in x.function.parameters):
304+
if isinstance(x, (SolidityVariableComposed, Constant)) or (
305+
x.function.visibility in ["public", "external"] and x in x.function.parameters
306+
):
304307
return set([x])
305308

306309
function_dependencies = {}
307-
function_dependencies['context'] = {}
310+
function_dependencies["context"] = {}
308311
lvalues = []
309312

310313
for node in x.function.nodes:
@@ -322,8 +325,8 @@ def compute_must_dependencies(x):
322325
lvalue = lvalue_details[0]
323326
ir = lvalue_details[2]
324327

325-
if not lvalue in function_dependencies['context']:
326-
function_dependencies['context'][lvalue] = set()
328+
if not lvalue in function_dependencies["context"]:
329+
function_dependencies["context"][lvalue] = set()
327330
read: Union[List[Union[LVALUE, SolidityVariableComposed]], List[SlithIRVariable]]
328331

329332
if isinstance(ir, Index):
@@ -333,21 +336,25 @@ def compute_must_dependencies(x):
333336
else:
334337
read = ir.read
335338
for v in read:
336-
#if not isinstance(v, Constant):
337-
function_dependencies['context'][lvalue].add(v)
338-
function_dependencies['context'] = convert_to_non_ssa(function_dependencies['context'])
339+
# if not isinstance(v, Constant):
340+
function_dependencies["context"][lvalue].add(v)
341+
function_dependencies["context"] = convert_to_non_ssa(function_dependencies["context"])
339342

340343
must_dependencies = set()
341-
if x in function_dependencies['context']:
342-
dependencies = list(function_dependencies['context'][x])
343-
for i in range(0, len(dependencies)):
344-
result = compute_must_dependencies(dependencies[i])
345-
if i > 0:
346-
must_dependencies = must_dependencies.intersection(result)
347-
else:
348-
must_dependencies = must_dependencies.union(result)
344+
data_dependencies = (
345+
list(function_dependencies["context"][x])
346+
if function_dependencies["context"] is not None
347+
else []
348+
)
349+
for i, data_dependency in enumerate(data_dependencies):
350+
result = compute_must_dependencies(data_dependency)
351+
if i > 0:
352+
must_dependencies = must_dependencies.intersection(result)
353+
else:
354+
must_dependencies = must_dependencies.union(result)
349355
return must_dependencies
350356

357+
351358
# endregion
352359
###################################################################################
353360
###################################################################################

0 commit comments

Comments
 (0)