diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7fd2f83b8..04d3ac50c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,6 +37,8 @@ For your proposed change, you need to have: * **an issue** (in the issue tracker) which describe your bug or feature * **a feature branch** in your git fork +Make sure your code change follows the style guide. To format your code, run `./tools/format-code.sh`. + ### Refer the Issue The commit message needs to link to the issue. This cross-reference is [very important](http://ariya.ofilabs.com/2012/01/small-scale-software-craftsmanship.html) for the following reasons. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 59d4bf0d4..e5196045a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,5 +1,16 @@ jobs: +- job: 'CodeQuality' + pool: + vmImage: 'macOS 10.13' + steps: + - script: brew install clang-format && clang-format --version + displayName: 'Install clang-format' + - script: bash ./tools/format-code.sh + displayName: 'Run code formatter' + - script: git diff --quiet HEAD + displayName: 'Check if the styling guide is followed' + - job: 'amd64_linux_gcc' pool: vmImage: 'ubuntu-18.04' diff --git a/tools/check-style.bat b/tools/check-style.bat deleted file mode 100644 index e412b30e8..000000000 --- a/tools/check-style.bat +++ /dev/null @@ -1,20 +0,0 @@ -@echo off - -set ROOT_DIR=%CD% - -set CONFIG= -set CONFIG=%CONFIG% --indent=spaces=4 -set CONFIG=%CONFIG% --style=otbs -set CONFIG=%CONFIG% --indent-labels -set CONFIG=%CONFIG% --pad-header -set CONFIG=%CONFIG% --pad-oper -set CONFIG=%CONFIG% --unpad-paren -set CONFIG=%CONFIG% --keep-one-line-blocks -set CONFIG=%CONFIG% --keep-one-line-statements -set CONFIG=%CONFIG% --convert-tabs -set CONFIG=%CONFIG% --indent-preprocessor -set CONFIG=%CONFIG% --align-pointer=type -set CONFIG=%CONFIG% --suffix=none - -call astyle %CONFIG% !ROOT_DIR!\..\src\*.cpp -call astyle %CONFIG% !ROOT_DIR!\..\src\*.h diff --git a/tools/format-code.sh b/tools/format-code.sh new file mode 100755 index 000000000..b88c5a093 --- /dev/null +++ b/tools/format-code.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +cwd=$(pwd) +clang-format -i --style=WebKit $cwd/src/*.h $cwd/src/*.cpp