From 3c512806e46b2b6b4d130a2235ea37a89190c977 Mon Sep 17 00:00:00 2001 From: burnettk Date: Tue, 30 May 2023 15:07:00 -0400 Subject: [PATCH] stop codecov comments and commit WIP --- .github/codecov.yml | 2 + .../bin/python_comment_cleanup.sh | 55 ++++++++++++++++--- 2 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 .github/codecov.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 000000000..a45a954aa --- /dev/null +++ b/.github/codecov.yml @@ -0,0 +1,2 @@ +# avoiding posting comments on PRs about coverage +comment: false diff --git a/spiffworkflow-backend/bin/python_comment_cleanup.sh b/spiffworkflow-backend/bin/python_comment_cleanup.sh index 94a0f694f..03e30e0b8 100755 --- a/spiffworkflow-backend/bin/python_comment_cleanup.sh +++ b/spiffworkflow-backend/bin/python_comment_cleanup.sh @@ -14,7 +14,6 @@ matches_filename_pattern() { # Remove file extension and capitalize the first letter local expected_comment=$(basename "$file_name" .py) - expected_comment_with_first_letter_capitalized="${expected_comment^}" if grep -Eq "\"\"\"${expected_comment}\.\"\"\"" <<< "$comment_line"; then @@ -28,14 +27,56 @@ matches_filename_pattern() { fi } +# this is the sort of garbage we want to remove: +# class InvalidLogLevelError(Exception): +# """InvalidLogLevelError.""" + +# Function to remove useless comments after class declarations +remove_useless_comments() { + local file_name="$1" + + echo "grepping" + matches=$(ggrep --group-separator=HOTSEP -B 1 -E '^\s*"""' "$file_name" || echo '') + if [[ -n "$matches" ]]; then + matches="${matches}\nHOTSEP" + echo -e "$matches" + while read -d'HOTSEP' -r match || [ -n "$match" ]; do + echo "match: ${match}" + if [[ -n "$match" ]]; then + code_line_of_match=$(head -n 1 <<< "$match") + comment_line_of_match=$(sed -n '2 p' <<< "$match") + echo "code_line_of_match: ${code_line_of_match}" + comment_line_of_match=$(sed -n '2 p' <<< "$match") + echo "comment_line_of_match: ${comment_line_of_match}" + comment_contents=$(hot_sed -E 's/^\s*"""(.*)\.""".*$/\1/' <<< "$comment_line_of_match") + echo "comment_contents: ${comment_contents}" + if grep -Eiq "^\s*(def|class) ${comment_contents}\(" <<< "$code_line_of_match"; then + # Remove line from file matching comment_line + hot_sed -i "/${comment_line_of_match}/d" "$file_name" + fi + fi + done <<< $matches + fi +} + # Process each Python file in the "src" and "tests" directories for file in $(find src tests -type f -name '*.py'); do # Read the first line of the file - read -r first_line < "$file" - - # Check if the first line matches the expected comment pattern - if matches_filename_pattern "$file" "$first_line"; then - # Remove the comment from the file - hot_sed -i '1d' "$file" + if grep -Eq '/logging_service' <<< "$file"; then + echo "processing file that we hand picked for debugging: ${file}" + remove_useless_comments "$file" fi + + # this is already done + # if [ -s "$file" ]; then + # # read -r first_line < "$file" + # + # # Check if the first line matches the expected comment pattern + # # if matches_filename_pattern "$file" "$first_line"; then + # # # Remove the comment from the file + # # hot_sed -i '1d' "$file" + # # + # # # Remove useless comments after class declarations + # # fi + # fi done