@@ -38,20 +38,50 @@ 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+ new_line_num=${BASH_REMATCH[1]}
58+ elif [[ "$line" =~ ^(\+[^+].*) ]]; then
59+ # This is an added line (not a +++ header)
60+ added_line="${line:1}" # Remove leading +
61+ char_count=${#added_line}
5062
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"
63+ # Skip JNI method signatures and calls to avoid false positives
64+ # These are auto-generated names that can't be shortened
65+ if [[ $char_count -gt 80 ]]; then
66+ # Check if this is a JNI method signature, call, or parameter line that should be ignored
67+ if [[ "$added_line" =~ JNIEXPORT.*JNICALL.*Java_com_wolfssl_ ]] || \
68+ [[ "$added_line" =~ Java_com_wolfssl_.*\( ]] || \
69+ [[ "$added_line" =~ ^[[:space:]]*return[[:space:]]+Java_com_wolfssl_.* ]] || \
70+ [[ "$added_line" =~ ^[[:space:]]*\(JNIEnv\*[[:space:]]+env.*\) ]]; then
71+ echo "⚠️ $file:$new_line_num - Skipping JNI method signature/call/parameters ($char_count characters)"
72+ echo " Line: $added_line"
73+ else
74+ echo "❌ $file:$new_line_num - Line too long ($char_count characters)"
75+ echo " Line: $added_line"
76+ echo "violation" >> "$violations_file"
77+ fi
78+ fi
79+ # Increment line number for new file after processing each added line
80+ new_line_num=$((new_line_num + 1))
81+ elif [[ "$line" =~ ^[[:space:]] ]]; then
82+ # Context line (unchanged) - increment new file line number
83+ new_line_num=$((new_line_num + 1))
84+ # Removed lines (starting with -) don't affect new file line numbers
5585 fi
5686 done
5787 fi
0 commit comments