(ci): add cmake formater and linter
Description
Use cmake-format to format and check cmake files and cmake-lint as linter.
You can see the result on Sight (with some patch and correction !): sight!639 (merged)
Closes #31 (closed)
How to test it?
- Install cmake-format and cmake-lint:
sudo apt install cmake-format cmake-lint
- Launch unit tests
- Try on Sight:
cd src/Sight... find . \( -type f -and \( -iname "*.cmake" -or -iname "CMakeLists.txt" \) \) -exec sh -c "echo ' ' >> {}" \; git add * sheldon -f
tips:
find . \( -type f -and \( -iname "*.cmake" -or -iname "CMakeLists.txt" \) \) -exec sh -c "echo ' ' >> {}" \;
will add a blank line in all cmake file allowing us to easily test sheldon on it
Note
The linter has been castrated to allow current code to be modified and pushed (as the formatting alone is still useful). It is strongly advised to restore default settings later, especially the regex that allows uppercase local variable.
This should be adapted:
format:
line_width: 120
tab_size: 4
use_tabchars: false
dangle_parens: true
line_ending: "unix"
autosort: true
markup:
enable_markup: false
lint:
local_var_pattern: "[a-zA-Z_][a-zA-Z0-9_]+"
argument_var_pattern: "[a-zA-Z_][a-zA-Z0-9_]+"
public_var_pattern: '[a-zA-Z][a-zA-Z0-9_]+'
macro_pattern: "[0-9a-z_]+"
max_statement_spacing: 2
max_returns: 12
max_branches: 24
max_arguments: 10
max_localvars: 30
max_statements: 100
Edited by Didier WECKMANN