Commit 23f3d6bc authored by Nicolas Carion's avatar Nicolas Carion

Add script to apply clang-tidy and clang-format to the project

parent c020f27c
---
Checks: 'readability-simplify-boolean-expr, modernize-use-override, readability-redundant-smartptr-get, readability-redundant-control-flow, readability-non-const-parameter, readability-misplaced-array-index, readability-misleading-indentation, readability-implicit-bool-cast, readability-else-after-return, readability-delete-null-pointer, readability-container-size-empty, readability-avoid-const-params-in-decls, performance-unnecessary-value-param, performance-unnecessary-copy-initialization, performance-implicit-cast-in-loop, performance-for-range-copy, modernize-use-using, modernize-use-nullptr, modernize-use-equals-default, modernize-use-bool-literals, modernize-use-auto, modernize-shrink-to-fit, modernize-return-braced-init-list, modernize-redundant-void-arg'
CheckOptions:
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
- { key: readability-identifier-naming.PrivateMemberPrefix, value: m_ }
- { key: readability-identifier-naming.StructCase, value: CamelCase }
- { key: readability-identifier-naming.FunctionCase, value: camelBack }
- { key: readability-identifier-naming.VariableCase, value: lower_case }
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
- { key: readability-simplify-boolean-expr.ChainedConditionalReturn, value: 1 }
- { key: readability-simplify-boolean-expr.ChainedConditionalAssignment, value: 1 }
- { key: readability-implicit-bool-cast.AllowConditionalPointerCasts, value: 1 }
...
#!/bin/bash
if [ -f compile_commands.json ]; then
echo "Using the existing compilation db"
else
echo "Generating the compile db"
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
fi
echo "Retrieving the list of files to process..."
git ls-files > file_list
touch to_process
touch headers
echo "Cleaning the list of files to process..."
for file in `cat file_list`;
do
if grep -Fq "${file}" compile_commands.json
then
echo $file >> to_process
fi
if echo $file | grep -q "\.[ih][p]*$"
then
echo $file >> headers
fi
done;
echo "Formating source files"
parallel -j 8 clang-format -i -style=file {} :::: to_process
echo "Formating header files"
parallel -j 8 clang-format -i -style=file {} :::: headers
echo "Linting"
parallel -j 8 clang-tidy -fix -config="" {} :::: to_process
echo "Reformating source files"
parallel -j 8 clang-format -i -style=file {} :::: to_process
echo "Reformating header files"
parallel -j 8 clang-format -i -style=file {} :::: headers
rm file_list
rm to_process
rm headers
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment