mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-01-11 18:14:20 +00:00
stop codecov comments and commit WIP
This commit is contained in:
parent
7b2f75c349
commit
3c512806e4
2
.github/codecov.yml
vendored
Normal file
2
.github/codecov.yml
vendored
Normal file
@ -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
|
# Remove file extension and capitalize the first letter
|
||||||
local expected_comment=$(basename "$file_name" .py)
|
local expected_comment=$(basename "$file_name" .py)
|
||||||
|
|
||||||
expected_comment_with_first_letter_capitalized="${expected_comment^}"
|
expected_comment_with_first_letter_capitalized="${expected_comment^}"
|
||||||
|
|
||||||
if grep -Eq "\"\"\"${expected_comment}\.\"\"\"" <<< "$comment_line"; then
|
if grep -Eq "\"\"\"${expected_comment}\.\"\"\"" <<< "$comment_line"; then
|
||||||
@ -28,14 +27,56 @@ matches_filename_pattern() {
|
|||||||
fi
|
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
|
# Process each Python file in the "src" and "tests" directories
|
||||||
for file in $(find src tests -type f -name '*.py'); do
|
for file in $(find src tests -type f -name '*.py'); do
|
||||||
# Read the first line of the file
|
# Read the first line of the file
|
||||||
read -r first_line < "$file"
|
if grep -Eq '/logging_service' <<< "$file"; then
|
||||||
|
echo "processing file that we hand picked for debugging: ${file}"
|
||||||
# Check if the first line matches the expected comment pattern
|
remove_useless_comments "$file"
|
||||||
if matches_filename_pattern "$file" "$first_line"; then
|
|
||||||
# Remove the comment from the file
|
|
||||||
hot_sed -i '1d' "$file"
|
|
||||||
fi
|
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
|
done
|
||||||
|
Loading…
x
Reference in New Issue
Block a user