stop codecov comments and commit WIP
This commit is contained in:
parent
7b2f75c349
commit
3c512806e4
|
@ -0,0 +1,2 @@
|
|||
# avoiding posting comments on PRs about coverage
|
||||
comment: false
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue