mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-20 05:13:11 -07:00
Fix the project code style, as it is not consistent. (#236)
Fixes #202 This PR fixes code style for the project files. The Problem Different files in the project use different code style. That is not consistent and leads to harder maintenance of the project. Description of the changes: Have investigated and determined the most used code style across the given codebase Have configured IDE and applied code style to all project files. Have crafted clang-formatter config. see https://clang.llvm.org/docs/ClangFormat.html https://clang.llvm.org/docs/ClangFormatStyleOptions.html Some cases were fixed manually How changes were validated: manual/ad-hoc testing, automated testing All tests pass as before because these are only code style changes. Additional Please review, and let me know if I have any mistake in the code style. In case of any mistake, I will change the configuration and re-apply it to the project.
This commit is contained in:
parent
c77f1de84c
commit
2826d37056
237 changed files with 12824 additions and 11843 deletions
53
Tools/Scripts/clang-format/clang-format-all.sh
Normal file
53
Tools/Scripts/clang-format/clang-format-all.sh
Normal file
|
@ -0,0 +1,53 @@
|
|||
#!/bin/bash
|
||||
|
||||
function usage {
|
||||
echo "Usage: $0 DIR..."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Variable that will hold the name of the clang-format command
|
||||
FMT=""
|
||||
|
||||
# Some distros just call it clang-format. Others (e.g. Ubuntu) are insistent
|
||||
# that the version number be part of the command. We prefer clang-format if
|
||||
# that's present, otherwise we work backwards from highest version to lowest
|
||||
# version.
|
||||
for clangfmt in clang-format{,-{4,3}.{9,8,7,6,5,4,3,2,1,0}}; do
|
||||
if which "$clangfmt" &>/dev/null; then
|
||||
FMT="$clangfmt"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# Check if we found a working clang-format
|
||||
if [ -z "$FMT" ]; then
|
||||
echo "failed to find clang-format"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SRC_PATH="$@"
|
||||
if [ -z "$SRC_PATH" ]; then
|
||||
SRC_PATH="../../../src"
|
||||
fi
|
||||
|
||||
# Check all of the arguments first to make sure they're all directories
|
||||
for dir in "$SRC_PATH"; do
|
||||
if [ ! -d "${dir}" ]; then
|
||||
echo "${dir} is not a directory"
|
||||
usage
|
||||
fi
|
||||
done
|
||||
|
||||
# Run clang-format -i on all of the things
|
||||
for dir in "$SRC_PATH"; do
|
||||
pushd "${dir}" &>/dev/null
|
||||
find . \
|
||||
\( -name '*.c' \
|
||||
-o -name '*.cc' \
|
||||
-o -name '*.cpp' \
|
||||
-o -name '*.h' \
|
||||
-o -name '*.hh' \
|
||||
-o -name '*.hpp' \) \
|
||||
-exec "${FMT}" -style=file -i '{}' \;
|
||||
popd &>/dev/null
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue