@@ -38,20 +38,52 @@ jobs:
3838 # Check each changed file
3939 while IFS= read -r file; do
4040 if [[ -f "$file" ]]; then
41+ # Skip WolfCryptProvider.java as it contains service mappings
42+ # that legitimately exceed 80 characters
43+ if [[ "$file" == "src/main/java/com/wolfssl/provider/jce/WolfCryptProvider.java" ]]; then
44+ echo "⚠️ Skipping $file (contains security service mappings)"
45+ continue
46+ fi
47+
4148 echo "Checking: $file"
4249
43- # Get added lines with line numbers and check their length
50+ # Get added lines with actual file line numbers and check their length
51+ new_line_num=0
4452 git diff "origin/$BASE_BRANCH"...HEAD "$file" | \
45- grep -n -E '^\+[^+]' | \
46- while IFS=':' read -r line_num added_line; do
47- # Remove the leading +
48- actual_line="${added_line:1}"
49- char_count=${#actual_line}
53+ while IFS= read -r line; do
54+ # Track line numbers from diff headers - format: @@ -old_start,old_count +new_start,new_count @@
55+ if [[ "$line" =~ ^@@.*\+([0-9]+) ]]; then
56+ # Extract starting line number for new file (after +)
57+ # Subtract 1 because we'll increment before processing first line
58+ new_line_num=$((${BASH_REMATCH[1]} - 1))
59+ elif [[ "$line" =~ ^(\+[^+].*) ]]; then
60+ # This is an added line (not a +++ header)
61+ # Increment line number BEFORE processing (since this line exists in new file)
62+ new_line_num=$((new_line_num + 1))
63+ added_line="${line:1}" # Remove leading +
64+ char_count=${#added_line}
5065
51- if [[ $char_count -gt 80 ]]; then
52- echo "❌ $file:$line_num - Line too long ($char_count characters)"
53- echo " Line: $actual_line"
54- echo "violation" >> "$violations_file"
66+ # Skip JNI method signatures and calls to avoid false positives
67+ # These are auto-generated names that can't be shortened
68+ if [[ $char_count -gt 80 ]]; then
69+ # Check if this is a JNI method signature, call, or parameter line that should be ignored
70+ if [[ "$added_line" =~ JNIEXPORT.*JNICALL.*Java_com_wolfssl_ ]] || \
71+ [[ "$added_line" =~ Java_com_wolfssl_.*\( ]] || \
72+ [[ "$added_line" =~ ^[[:space:]]*return[[:space:]]+Java_com_wolfssl_.* ]] || \
73+ [[ "$added_line" =~ ^[[:space:]]*\(JNIEnv\*[[:space:]]+env.*\) ]] || \
74+ [[ "$added_line" =~ ^[[:space:]]*JNIEnv\*[[:space:]]+env.* ]]; then
75+ echo "⚠️ $file:$new_line_num - Skipping JNI method signature/call/parameters ($char_count characters)"
76+ echo " Line: $added_line"
77+ else
78+ echo "❌ $file:$new_line_num - Line too long ($char_count characters)"
79+ echo " Line: $added_line"
80+ echo "violation" >> "$violations_file"
81+ fi
82+ fi
83+ elif [[ "$line" =~ ^[[:space:]] ]]; then
84+ # Context line (unchanged) - increment new file line number
85+ new_line_num=$((new_line_num + 1))
86+ # Removed lines (starting with -) don't affect new file line numbers
5587 fi
5688 done
5789 fi
0 commit comments