iterate on function crusher script

This commit is contained in:
burnettk 2023-04-28 22:37:17 -04:00
parent 64356e8796
commit 247c260541
3 changed files with 11 additions and 13 deletions

View File

@ -18,10 +18,19 @@ list_of_unused_things="$(dead | grep -E '^[a-z].*is never read')"
while read -r line; do
function_name="$(echo "$line" | awk '{print $1}')"
echo "function_name: ${function_name}"
echo "possible function_name: ${function_name}"
file_name_and_line_number="$(echo "$line" | perl -p -e "s/.*is never read, defined in //g")"
file_name="$(echo "$file_name_and_line_number" | awk -F ':' '{print $1}')"
if ! grep "def $function_name" "$file_name" >/dev/null 2>&1; then
echo "skipping $function_name in ${file_name} because it's not a function"
continue
fi
if grep -E codemod <<< "$file_name" >/dev/null 2>&1; then
echo "skipping ${file_name} because it's a codemod file"
continue
fi
echo "trying to remove $function_name from: ${file_name}"
if python bin/codemod/update_file_to_remove_function.py "$file_name" "$function_name"; then
# TODO: run exhaustive tests, and if they pass, report success
echo "function ${function_name} removed from ${file_name}. yay!"

View File

@ -13,7 +13,7 @@ def remove_function(filename: str, function_name: str) -> None:
bowler_query = (Query(filename)
.select_function(function_name)
.modify(remove_statement)
.execute(write=True))
.execute(write=True, silent=True, interactive=False))
if len(bowler_query.exceptions) > 0:
print(f"Failed to remove function {function_name} from {filename}.")

View File

@ -11,17 +11,6 @@ from spiffworkflow_backend.services.process_instance_processor import (
from spiffworkflow_backend.services.process_instance_service import (
ProcessInstanceService,
)
def print_process_instance_count(process_model_identifier_ticket: str) -> None:
"""Print process instance count."""
process_instances = ProcessInstanceModel.query.filter_by(
process_model_identifier=process_model_identifier_ticket
).all()
process_instance_count = len(process_instances)
print(f"process_instance_count: {process_instance_count}")
def main():
"""Main."""
app = get_hacked_up_app_for_script()