diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..a99870e6b --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,22 @@ +--- + +# For now, we just use the default checks with some additions and exceptions +# based on what actually passes. In the future, this should be turned into a +# blacklist, like so: +# +# ### +# # First enable all, then disable the ones we do not want: +# # * -abseil-*: not applicable +# # * -android-*: not applicable +# # * -objc-*: not applicable +# # * -fuchsia-*: not applicable +# # * -mpi-*: not applicable +# # * -performance-*: not relevant +# # * -llvm-include-order': not our style +# # Checks: '*,-abseil-*,-android-*,-objc-*,-fuchsia-*,-mpi-*,-performance-*,-llvm-include-order' +# ### +# +Checks: 'readability-braces-around-statements,google-readability-braces-around-statements,hicpp-braces-around-statements,readability-container-size-empty,readability-inconsistent-declaration-parameter-name,bugprone-macro-parentheses,bugprone-bool-pointer-implicit-conversion,bugprone-suspicious-string-compare,cppcoreguidelines-pro-type-member-init' + +# Uncomment this to make clang-tidy fail on any findings: +WarningsAsErrors: '*' diff --git a/.travis.yml b/.travis.yml index f3ca9d605..63ebcfcad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,39 +12,7 @@ branches: jobs: include: - - name: "Build with GCC, run tests" - env: TRAVIS_CACHE_ID=focal - cache: - directories: - - $HOME/.ccache-focal-gcc - - $HOME/.tox-cache - script: - # Fetch our current Ubuntu 20.04 CI image from Docker Hub - # (automatically built by Docker): - - docker pull hlwm/ci:focal - - # Build ad-hoc image, using hub image as cache - # (=> does not actually build from scratch if the Dockerfile is - # the same): - - docker build -t focal --cache-from hlwm/ci:focal - does not actually build from scratch if the Dockerfile is - # the same): - - docker build -t trusty --cache-from hlwm/ci:trusty - - &2 "Error: Cannot handle program name: $progname" - exit 1 -fi - -# Extract the source file from the call (simply assume it is the last -# argument): -sourcefile=${BASH_ARGV[0]} - -# Make sure it is a call for compilation: -if [[ $sourcefile != *.cpp && $sourcefile != *.c ]]; then - exit 0 -fi - -if [[ ! -v CLANG_TIDY_BUILD_DIR ]]; then - # This is probably a sanity check invocation by cmake, so we should not run - # clang-tidy. - exit 0 -fi - -### -# All clang-tidy arguments and its configuration must be defined within this -# script, so that ccache can detect changes to the configuration. -### -checks="" -function add_check() { - checks=${checks:+$checks,}$1 -} - -add_check readability-braces-around-statements -add_check google-readability-braces-around-statements -add_check hicpp-braces-around-statements -add_check readability-container-size-empty -add_check readability-inconsistent-declaration-parameter-name -add_check bugprone-macro-parentheses -add_check bugprone-bool-pointer-implicit-conversion -add_check bugprone-suspicious-string-compare -add_check cppcoreguidelines-pro-type-member-init - -clang_tidy_args="-header-filter=.* -extra-arg=-Wno-unknown-warning-option -p=${CLANG_TIDY_BUILD_DIR} -config={} -warnings-as-errors=* -checks=$checks" - -# Run clang-tidy, but hide its output unless it fails (non-failing stdout -# confuses ccache!) -if ! out="$(clang-tidy-10 $clang_tidy_args "$sourcefile" 2>&1)"; then - echo "$out" - exit 1 -fi