237e62dfd09da3c600336eb626823b32ae94f8cd
[geeqie.git] / scripts / clang-tidy-check.sh
1 #! /bin/sh
2 #**********************************************************************
3 # Copyright (C) 2024 - The Geeqie Team
4 #
5 # Author: Colin Clark
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #**********************************************************************
21
22 ## @file
23 ## @brief Run clang-tidy on all source files.
24 ##
25
26 if [ ! -d ".git" ] || [ ! -d "src" ] || [ ! -f "geeqie.1" ]
27 then
28         printf '%s\n' "This is not a Geeqie project folder"
29         exit 1
30 fi
31
32 i=0
33
34 secs_start=$(cut --delimiter='.' --fields=1 < /proc/uptime)
35 total=$(find src -name "*.cc" | wc --lines)
36
37 while read -r file
38 do
39         i=$((i + 1))
40         printf '%d/%d %s\n' "$i" "$total" "$file"
41         clang-tidy --config-file ./.clang-tidy -p ./build "$file" 2>/dev/null
42
43         secs_now=$(cut --delimiter='.' --fields=1 < /proc/uptime)
44
45         elapsed_time=$(( secs_now - secs_start ))
46         remaining_files=$(( total - i ))
47         average_time=$(( elapsed_time / i ))
48         estimated=$(( average_time * remaining_files ))
49
50         printf 'Remaining: %dm:%ds\n' $((estimated%3600/60)) $((estimated%60))
51 done << EOF
52 $(find src -name "*.cc" | sort)
53 EOF