-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathcheck-code-format.sh
executable file
·50 lines (41 loc) · 1.49 KB
/
check-code-format.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Copyright 2019-2023 Lawrence Livermore National Security, LLC and other
# Variorum Project Developers. See the top-level LICENSE file for details.
#
# SPDX-License-Identifier: MIT
# check format for all *.cpp, *.h, and *.c files in src/ directory
# exclude files in thirdparty_builtin/ (gtest source files)
# exclude files in fortran/ (EP source files)
function check_format_files_cpp_c_h {
if ! command -v astyle &> /dev/null; then
echo -e "'astyle' not found: see https://astyle.sourceforge.net/ for installation info"
exit
fi
echo -e "Checking format of cpp/c/h files using astyle"
./scripts/check-cpp-c-format.sh
}
function check_format_files_rst {
if ! command -v rstfmt &> /dev/null; then
echo -e "'rstfmt' not found: this package can be installed using pip"
exit
fi
echo -e "Checking format of rst documentation using rstfmt"
./scripts/check-rst-format.sh
}
function check_format_files_python {
if ! command -v flake8 &> /dev/null; then
echo -e "'flake8' not found: this package can be installed using pip"
exit
fi
if ! command -v black &> /dev/null; then
echo -e "'black' not found: this package can be installed using pip"
exit
fi
echo -e "Checking format of python files using flake and black"
flake8
black --diff --check --exclude "/(src/thirdparty_builtin/googletest|build|src/docs)/" .
}
check_format_files_cpp_c_h
check_format_files_rst
check_format_files_python
#