Skip to content

Commit

Permalink
Fix all pylint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
montyly committed Sep 2, 2020
1 parent 683ebb9 commit 70e609e
Show file tree
Hide file tree
Showing 224 changed files with 4,097 additions and 2,400 deletions.
87 changes: 0 additions & 87 deletions examples/scripts/call_graph.py

This file was deleted.

39 changes: 0 additions & 39 deletions examples/scripts/convert_to_evm_ins.py

This file was deleted.

4 changes: 2 additions & 2 deletions examples/scripts/convert_to_ir.py
Expand Up @@ -5,7 +5,7 @@

if len(sys.argv) != 2:
print("python function_called.py functions_called.sol")
exit(-1)
sys.exit(-1)

# Init slither
slither = Slither(sys.argv[1])
Expand All @@ -21,7 +21,7 @@
for node in nodes:
if node.expression:
print("Expression:\n\t{}".format(node.expression))
irs = convert_expression(node.expression)
irs = convert_expression(node.expression, node)
print("IR expressions:")
for ir in irs:
print("\t{}".format(ir))
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/data_dependency.py
@@ -1,15 +1,15 @@
import sys

from slither import Slither
from slither.analyses.data_dependency.data_dependency import (
is_dependent,
is_tainted,
pprint_dependency,
)
from slither.core.declarations.solidity_variables import SolidityVariableComposed

if len(sys.argv) != 2:
print("Usage: python data_dependency.py file.sol")
exit(-1)
sys.exit(-1)

slither = Slither(sys.argv[1])

Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/export_dominator_tree_to_dot.py
Expand Up @@ -4,7 +4,7 @@

if len(sys.argv) != 2:
print("python export_dominator_tree_to_dot.py contract.sol")
exit(-1)
sys.exit(-1)

# Init slither
slither = Slither(sys.argv[1])
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/export_to_dot.py
Expand Up @@ -4,7 +4,7 @@

if len(sys.argv) != 2:
print("python function_called.py contract.sol")
exit(-1)
sys.exit(-1)

# Init slither
slither = Slither(sys.argv[1])
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/functions_called.py
Expand Up @@ -3,7 +3,7 @@

if len(sys.argv) != 2:
print("python functions_called.py functions_called.sol")
exit(-1)
sys.exit(-1)

# Init slither
slither = Slither(sys.argv[1])
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/functions_writing.py
Expand Up @@ -3,7 +3,7 @@

if len(sys.argv) != 2:
print("python function_writing.py functions_writing.sol")
exit(-1)
sys.exit(-1)

# Init slither
slither = Slither(sys.argv[1])
Expand Down
12 changes: 6 additions & 6 deletions examples/scripts/possible_paths.py
Expand Up @@ -84,8 +84,8 @@ def all_function_definitions(function):
]


def __find_target_paths(target_function, current_path=[]):

def __find_target_paths(target_function, current_path=None):
current_path = current_path if current_path else []
# Create our results list
results = set()

Expand Down Expand Up @@ -184,17 +184,17 @@ def parse_args():
targets = resolve_functions(args.targets)

# Print out all target functions.
print(f"Target functions:")
print("Target functions:")
for target in targets:
print(f"-{target.contract.name}.{target.full_name}")
print("\n")

# Obtain all paths which reach the target functions.
reaching_paths = find_target_paths(targets)
reaching_functions = set([y for x in reaching_paths for y in x if y not in targets])
reaching_functions = {y for x in reaching_paths for y in x if y not in targets}

# Print out all function names which can reach the targets.
print(f"The following functions reach the specified targets:")
print("The following functions reach the specified targets:")
for function_desc in sorted([f"{f.canonical_name}" for f in reaching_functions]):
print(f"-{function_desc}")
print("\n")
Expand All @@ -205,6 +205,6 @@ def parse_args():
]

# Print a sorted list of all function paths which can reach the targets.
print(f"The following paths reach the specified targets:")
print("The following paths reach the specified targets:")
for reaching_path in sorted(reaching_paths_str):
print(f"{reaching_path}\n")
2 changes: 1 addition & 1 deletion examples/scripts/slithIR.py
Expand Up @@ -3,7 +3,7 @@

if len(sys.argv) != 2:
print("python slithIR.py contract.sol")
exit(-1)
sys.exit(-1)

# Init slither
slither = Slither(sys.argv[1])
Expand Down
8 changes: 4 additions & 4 deletions examples/scripts/taint_mapping.py
Expand Up @@ -58,7 +58,7 @@ def check_call(func, taints):
if __name__ == "__main__":
if len(sys.argv) != 2:
print("python taint_mapping.py taint.sol")
exit(-1)
sys.exit(-1)

# Init slither
slither = Slither(sys.argv[1])
Expand All @@ -79,11 +79,11 @@ def check_call(func, taints):
visit_node(function.entry_point, [])
print("All variables tainted : {}".format([str(v) for v in slither.context[KEY]]))

for function in contract.functions:
check_call(function, slither.context[KEY])

print(
"All state variables tainted : {}".format(
[str(v) for v in prev_taints if isinstance(v, StateVariable)]
)
)

for function in contract.functions:
check_call(function, slither.context[KEY])
2 changes: 1 addition & 1 deletion examples/scripts/variable_in_condition.py
Expand Up @@ -3,7 +3,7 @@

if len(sys.argv) != 2:
print("python variable_in_condition.py variable_in_condition.sol")
exit(-1)
sys.exit(-1)

# Init slither
slither = Slither(sys.argv[1])
Expand Down
9 changes: 8 additions & 1 deletion pyproject.toml
Expand Up @@ -9,5 +9,12 @@ missing-function-docstring,
unnecessary-lambda,
bad-continuation,
cyclic-import,
line-too-long
line-too-long,
invalid-name,
fixme,
too-many-return-statements,
too-many-ancestors,
logging-fstring-interpolation,
logging-not-lazy,
duplicate-code
"""
5 changes: 3 additions & 2 deletions scripts/json_diff.py
@@ -1,11 +1,12 @@
import sys
import json
from deepdiff import DeepDiff # pip install deepdiff
from pprint import pprint
from deepdiff import DeepDiff # pip install deepdiff


if len(sys.argv) != 3:
print("Usage: python json_diff.py 1.json 2.json")
exit(-1)
sys.exit(-1)

with open(sys.argv[1], encoding="utf8") as f:
d1 = json.load(f)
Expand Down

0 comments on commit 70e609e

Please sign in to comment.