@@ -115,22 +115,25 @@ jobs:
115
115
EOF
116
116
117
117
# Check for PHPUnit warnings and process them
118
- if grep -q "WARNINGS!\|There was.*warning " coverage-output.log; then
118
+ if grep -q "WARNINGS!" coverage-output.log; then
119
119
echo "Processing coverage warnings for checkstyle report..."
120
120
121
121
# Show warnings section for debugging
122
122
echo "--- Warnings Found ---"
123
- sed -n '/There was .*warning/,/WARNINGS!/p' coverage-output.log | head -10
123
+ sed -n '/There w .*warning/,/WARNINGS!/p' coverage-output.log | head -10
124
124
echo "--- End Warnings ---"
125
125
126
126
# Extract warnings to temporary file to avoid subshell issues
127
- sed -n '/There was.*warning/,/WARNINGS!/p' coverage-output.log > temp-warnings.txt
127
+ sed -n '/There w.*warning/,/WARNINGS!/p' coverage-output.log > temp-warnings.txt
128
+
129
+ # Track processed file:line combinations to avoid duplicates
130
+ declare -A processed_annotations
128
131
129
132
# Process each line
130
133
while IFS= read -r line; do
131
134
echo "Processing line: $line"
132
135
# Look for @covers warnings
133
- if [[ "$line" =~ \"@covers. *\"\ is\ invalid ]]; then
136
+ if [[ "$line" =~ \"@covers[^\"] *\"\ is\ invalid ]]; then
134
137
echo "Found @covers warning line: $line"
135
138
# Extract the @covers target - everything between quotes
136
139
if [[ "$line" =~ \"@covers\ ([^\"]+)\" ]]; then
@@ -146,13 +149,25 @@ jobs:
146
149
echo "Found test file: $TEST_FILE"
147
150
if LINE_NUM=$(grep -n "@covers.*$METHOD_NAME" "$TEST_FILE" | head -1 | cut -d: -f1); then
148
151
echo "Found line number: $LINE_NUM"
149
- # Escape XML characters and add checkstyle entry
150
- MESSAGE=$(echo "Invalid @covers annotation: $COVERS_TARGET" | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g')
151
- cat >> coverage-warnings.xml << EOF
152
+
153
+ # Create unique key for this file:line combination
154
+ FILE_LINE_KEY="$TEST_FILE:$LINE_NUM"
155
+
156
+ # Only process if we haven't seen this file:line before
157
+ if [[ -z "${processed_annotations[$FILE_LINE_KEY]}" ]]; then
158
+ echo "Adding annotation for $FILE_LINE_KEY"
159
+ processed_annotations[$FILE_LINE_KEY]=1
160
+
161
+ # Escape XML characters and add checkstyle entry
162
+ MESSAGE=$(echo "Invalid @covers annotation: $COVERS_TARGET" | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g')
163
+ cat >> coverage-warnings.xml << EOF
152
164
<file name="$TEST_FILE">
153
165
<error line="$LINE_NUM" column="1" severity="warning" message="$MESSAGE" source="phpunit.coverage"/>
154
166
</file>
155
167
EOF
168
+ else
169
+ echo "Skipping duplicate annotation for $FILE_LINE_KEY"
170
+ fi
156
171
fi
157
172
fi
158
173
fi
0 commit comments