@@ -30,11 +30,6 @@ if [ "$VISIT_IMPLICIT_CODE" == "true" ]; then
3030 options+=( " --visit-implicit-code" )
3131fi
3232
33- if [ " $IGNORE_HEADERS " == " true" ] && [ -n " $DATABASE " ]; then
34- cp $DATABASE /compile_commands.json $DATABASE /compile_commands_backup.json
35- sed -i ' s/-I\([^ ]*\)/-isystem\1/g' $DATABASE /compile_commands.json
36- fi
37-
3833pattern=' ^(.*?):([0-9]+):([0-9]+): (.+): (.+) \[(.*)\]$'
3934
4035if [[ -n " $ONLY_DIFF " ]]; then
@@ -68,93 +63,54 @@ echo 0 > "$warnings_file"
6863echo 0 > " $errors_file "
6964
7065declare -A warnings_seen
71-
66+ root_path=$( realpath -s " $ROOT_DIR " )
67+
7268echo " $output " | grep -E " $pattern " | while IFS= read -r line; do
7369 if [[ $line =~ $pattern ]]; then
74- relative_path =" ${BASH_REMATCH[1]} "
70+ absolute_path =" ${BASH_REMATCH[1]} "
7571 line_number=" ${BASH_REMATCH[2]} "
7672 column_number=" ${BASH_REMATCH[3]} "
7773 warning_type=" ${BASH_REMATCH[4]} "
7874 warning_message=" ${BASH_REMATCH[5]} "
7975 warning_code=" ${BASH_REMATCH[6]} "
8076
81- counter=0
82- if [[ " $relative_path " == /* ]]; then
83- absolute_path=$relative_path
84- else
85- for full_path in " ${files[@]} " ; do
86- if [[ " $( basename " $full_path " ) " == " $relative_path " ]]; then
87- absolute_path=" $full_path "
88- (( counter++ ))
89- fi
90- done
91- fi
92-
93- # This is incredibly bad, but I don't know how to properly handle the clazy output yet
94- if [ " $counter " -ne 1 ]; then
95- continue
96- fi
97-
9877 warning_key=" ${absolute_path} :${line_number} :${column_number} :${warning_code} "
78+ hash=$( echo -n " $warning_key " | md5sum | cut -d' ' -f1)
9979
100- if [[ -n " ${warnings_seen[$warning_key] } " ]]; then
80+ if [[ -n " ${warnings_seen[$hash] :- } " ]]; then
10181 continue
10282 fi
10383
10484 warnings_seen[" $warning_key " ]=1
10585
106- if [ " $IGNORE_HEADERS " != " true" ]; then
107- if [[ " $warning_type " == " warning" ]]; then
108- echo " warning file=$absolute_path ,line=$line_number ,col=$column_number ,$warning_message [$warning_code ]"
109- current_warnings=$( < " $warnings_file " )
110- (( current_warnings++ ))
111- echo " $current_warnings " > " $warnings_file "
112- fi
113-
114- if [[ " $warning_type " == " error" ]]; then
115- echo " error file=$absolute_path ,line=$line_number ,col=$column_number ,$warning_message [$warning_code ]"
116- current_errors=$( < " $errors_file " )
117- (( current_errors++ ))
118- echo " $current_errors " > " $errors_file "
119- fi
120-
121- elif [[ " ${files[@]} " =~ " $absolute_path " ]]; then
122-
123- if [[ " $warning_type " == " warning" ]]; then
124- echo " warning file=$absolute_path ,line=$line_number ,col=$column_number ,$warning_message [$warning_code ]"
125- current_warnings=$( < " $warnings_file " )
126- (( current_warnings++ ))
127- echo " $current_warnings " > " $warnings_file "
128- fi
129-
130- if [[ " $warning_type " == " error" ]]; then
131- echo " error file=$absolute_path ,line=$line_number ,col=$column_number ,$warning_message [$warning_code ]"
132- current_errors=$( < " $errors_file " )
133- (( current_errors++ ))
134- echo " $current_errors " > " $errors_file "
135- fi
136- fi
137-
138- if [[ " ${files[@]} " =~ " $absolute_path " ]]; then
139- if [[ " $warning_type " == " warning" ]]; then
140- echo " ::warning file=$absolute_path ,line=$line_number ,col=$column_number ::$warning_message [$warning_code ]"
141- fi
86+ if [[ " $IGNORE_EXTERNAL_FILES " == " true" && " $absolute_path " != " $root_path " * ]]; then
87+ continue
88+ fi
14289
143- if [[ " $warning_type " == " error" ]]; then
144- echo " ::error file=$absolute_path ,line=$line_number ,col=$column_number ::$warning_message [$warning_code ]"
145- fi
90+ if [[ " $IGNORE_HEADER_DEPS " == " true" ]] && [[ ! " ${files[@]} " =~ " $absolute_path " ]]; then
91+ continue
92+ fi
93+
94+ if [[ " $warning_type " == " warning" ]]; then
95+ echo " ::warning file=$absolute_path ,line=$line_number ,col=$column_number ::$warning_message [$warning_code ]"
96+ current_warnings=$( < " $warnings_file " )
97+ (( current_warnings++ ))
98+ echo " $current_warnings " > " $warnings_file "
14699 fi
100+
101+ if [[ " $warning_type " == " error" ]]; then
102+ echo " ::error file=$absolute_path ,line=$line_number ,col=$column_number ::$warning_message [$warning_code ]"
103+ current_errors=$( < " $errors_file " )
104+ (( current_errors++ ))
105+ echo " $current_errors " > " $errors_file "
106+ fi
147107 fi
148108done
149109
150110warnings_count=$( < " $warnings_file " )
151111errors_count=$( < " $errors_file " )
152112
153113echo " ::set-output name=errors-count::$errors_count "
154- echo " ::set-output name=warnings-count::$warnings_count "
155-
156- if [ " $IGNORE_HEADERS " == " true" ] && [ -n " $DATABASE " ]; then
157- mv $DATABASE /compile_commands_backup.json $DATABASE /compile_commands.json
158- fi
114+ echo " ::set-output name=warnings-count::$warnings_count "
159115
160116rm -f " $warnings_file " " $errors_file "
0 commit comments