Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1724 from advancedtelematic/feat/more-clang-tidy
Browse files Browse the repository at this point in the history
Feat/more clang tidy
  • Loading branch information
pattivacek authored Jul 15, 2020
2 parents 4744aed + 809e14e commit 8316765
Show file tree
Hide file tree
Showing 57 changed files with 205 additions and 338 deletions.
118 changes: 27 additions & 91 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,114 +1,62 @@
---
Checks: >-
clang-analyzer-*,
performance-*,
boost-*,
bugprone-*,
readability-*,-readability-else-after-return,-readability-identifier-naming,-readability-container-size-empty,-readability-redundant-declaration,-readability-magic-numbers,
modernize-*,-modernize-avoid-bind,-modernize-loop-convert,-modernize-use-using,-modernize-deprecated-headers,-modernize-pass-by-value,
cert-*,-cert-err58-cpp,-cert-env33-c,-cert-err60-cpp,
clang-analyzer-*,
cppcoreguidelines-*,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-init-variables,-cppcoreguidelines-owning-memory,
cppcoreguidelines-pro-*,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-type-const-cast,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
google-*,-google-runtime-references,-google-readability-todo,
hicpp-*,-hicpp-no-array-decay,-hicpp-no-assembler,-hicpp-signed-bitwise,-hicpp-vararg,
llvm-namespace-comment,
cppcoreguidelines-pro-*,-cppcoreguidelines-pro-type-reinterpret-cast,-cppcoreguidelines-pro-type-vararg,-cppcoreguidelines-pro-type-const-cast,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-cppcoreguidelines-pro-bounds-constant-array-index,cert-*,
-cert-err58-cpp,-cert-env33-c,-cert-err09-cpp,-cert-err60-cpp,-cert-err61-cpp, -cert-err61-cpp,
google-*,-google-runtime-references,-google-runtime-member-string-references,-google-explicit-constructor,-google-readability-todo,
misc-*, -misc-unused-parameters, -misc-macro-parentheses, -misc-throw-by-value-catch-by-reference, -misc-suspicious-enum-usage, -misc-non-private-member-variables-in-classes
misc-*,
modernize-*,-modernize-avoid-bind,-modernize-loop-convert,-modernize-use-trailing-return-type,
performance-*,
readability-*,-readability-else-after-return,-readability-identifier-naming,-readability-magic-numbers,
WarningsAsErrors: '*'
AnalyzeTemporaryDtors: false
CheckOptions:
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables
value: '1'
- key: cert-dcl59-cpp.HeaderFileExtensions
value: h,hh,hpp,hxx
value: h
- key: cert-err09-cpp.CheckThrowTemporaries
value: '1'
- key: cert-err61-cpp.CheckThrowTemporaries
value: '1'
- key: cert-oop11-cpp.IncludeStyle
value: llvm
- key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader
value: ''
- key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle
value: '0'
- key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
value: '0'
- key: google-build-namespaces.HeaderFileExtensions
value: h,hh,hpp,hxx
value: h
- key: google-global-names-in-headers.HeaderFileExtensions
value: h
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.BranchThreshold
value: '4294967295'
value: '100'
- key: google-readability-function-size.LineThreshold
value: '4294967295'
value: '1000'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: google-runtime-int.SignedTypePrefix
value: int
- key: google-runtime-int.TypeSuffix
value: ''
- key: google-runtime-int.UnsignedTypePrefix
value: uint
- key: google-runtime-references.WhiteListTypes
value: ''
- key: llvm-header-guard.HeaderFileExtensions
value: ',h,hh,hpp,hxx'
value: h
- key: llvm-namespace-comment.ShortNamespaceLines
value: '1'
value: '10'
- key: llvm-namespace-comment.SpacesBeforeComments
value: '1'
- key: misc-argument-comment.StrictMode
value: '0'
- key: misc-assert-side-effect.AssertMacros
value: assert
- key: misc-assert-side-effect.CheckFunctionCalls
value: '0'
- key: misc-dangling-handle.HandleClasses
value: 'std::basic_string_view;std::experimental::basic_string_view'
value: '2'
- key: misc-definitions-in-headers.HeaderFileExtensions
value: ',h,hh,hpp,hxx'
value: h
- key: misc-definitions-in-headers.UseHeaderFileExtension
value: '1'
- key: misc-misplaced-widening-cast.CheckImplicitCasts
value: '1'
- key: misc-move-constructor-init.IncludeStyle
value: llvm
- key: misc-sizeof-expression.WarnOnSizeOfCompareToConstant
value: '1'
- key: misc-sizeof-expression.WarnOnSizeOfConstant
value: '1'
- key: misc-sizeof-expression.WarnOnSizeOfThis
value: '1'
- key: misc-string-constructor.LargeLengthThreshold
value: '8388608'
- key: misc-string-constructor.WarnOnLargeLength
- key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables
value: '1'
- key: misc-suspicious-enum-usage.StrictMode
value: '0'
- key: misc-suspicious-missing-comma.MaxConcatenatedTokens
value: '5'
- key: misc-suspicious-missing-comma.RatioThreshold
value: '0.200000'
- key: misc-suspicious-missing-comma.SizeThreshold
value: '5'
- key: misc-suspicious-string-compare.StringCompareLikeFunctions
value: ''
- key: misc-suspicious-string-compare.WarnOnImplicitComparison
value: '1'
- key: misc-suspicious-string-compare.WarnOnLogicalNotComparison
value: '0'
- key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries
value: '1'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-auto.RemoveStars
value: '0'
- key: modernize-use-default-member-init.UseAssignment
Expand All @@ -117,26 +65,14 @@ CheckOptions:
value: '::std::vector;::std::list;::std::deque'
- key: modernize-use-emplace.SmartPointers
value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: modernize-use-transparent-functors.SafeMode
value: '0'
- key: performance-faster-string-find.StringLikeClasses
value: 'std::basic_string'
- key: performance-for-range-copy.WarnOnAllAutoCopies
value: '0'
- key: performance-inefficient-string-concatenation.StrictMode
value: '0'
- key: performance-type-promotion-in-math-fn.IncludeStyle
value: llvm
- key: performance-unnecessary-value-param.IncludeStyle
value: llvm
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
value: '1'
- key: readability-function-size.BranchThreshold
value: '4294967295'
value: '100'
- key: readability-function-size.LineThreshold
value: '4294967295'
value: '1000'
- key: readability-function-size.StatementThreshold
value: '800'
- key: readability-identifier-naming.AbstractClassCase
Expand Down Expand Up @@ -405,9 +341,9 @@ CheckOptions:
value: ''
- key: readability-identifier-naming.VirtualMethodSuffix
value: ''
- key: readability-implicit-bool-cast.AllowConditionalIntegerCasts
- key: readability-implicit-bool-conversion.AllowConditionalIntegerCasts
value: '0'
- key: readability-implicit-bool-cast.AllowConditionalPointerCasts
- key: readability-implicit-bool-conversion.AllowConditionalPointerCasts
value: '0'
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: '0'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ jobs:
run: docker run -v "$PWD:$PWD" -w "$PWD" $DARGS -t "$DOCKER_TAG" ./scripts/test.sh

static-checks:
name: Static checks on Debian Testing
name: Static checks on Ubuntu Focal
runs-on: ubuntu-latest
env:
DOCKER_TAG: docker.pkg.github.com/advancedtelematic/aktualizr/aktualizr-ci:debian-testing-master
DOCKERFILE: docker/Dockerfile.debian.testing
DOCKER_TAG: docker.pkg.github.com/advancedtelematic/aktualizr/aktualizr-ci:ubuntu-focal-master
DOCKERFILE: docker/Dockerfile.ubuntu.focal
DARGS: >-
-eCCACHE_DIR
-eTEST_CC=clang
Expand All @@ -74,9 +74,9 @@ jobs:
- uses: actions/[email protected]
with:
path: ${{ github.workspace }}/.ccache
key: debian-testing-${{ github.run_id }}
key: ubuntu-focal-${{ github.run_id }}
restore-keys: |
debian-testing-${{ github.run_id }}
debian-testing-
ubuntu-focal-${{ github.run_id }}
ubuntu-focal-
- name: Test
run: docker run -v "$PWD:$PWD" -w "$PWD" $DARGS -t "$DOCKER_TAG" ./scripts/test.sh
8 changes: 4 additions & 4 deletions .github/workflows/update-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
docker build --cache-from "$DOCKER_TAG" --pull -t "$DOCKER_TAG" -f "$DOCKERFILE" .
docker push "$DOCKER_TAG"
update-debian-testing:
name: Update Debian Testing Image
update-ubuntu-focal:
name: Update Ubuntu Focal Image
runs-on: ubuntu-latest
env:
DOCKER_TAG: docker.pkg.github.com/advancedtelematic/aktualizr/aktualizr-ci:debian-testing-master
DOCKERFILE: docker/Dockerfile.debian.testing
DOCKER_TAG: docker.pkg.github.com/advancedtelematic/aktualizr/aktualizr-ci:ubuntu-focal-master
DOCKERFILE: docker/Dockerfile.ubuntu-focal
steps:
- uses: actions/checkout@master
- name: Docker login
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ endif()
add_custom_target(build_tests)

# clang-check and clang-format
find_program(CLANG_FORMAT NAMES clang-format-8)
find_program(CLANG_TIDY NAMES clang-tidy-8)
find_program(CLANG_FORMAT NAMES clang-format-10)
find_program(CLANG_TIDY NAMES clang-tidy-10)

if(CLANG_FORMAT)
function(aktualizr_clang_format)
Expand All @@ -256,7 +256,7 @@ if(CLANG_FORMAT)
endforeach()
endfunction()
else()
message(WARNING "clang-format-8 not found, skipping")
message(WARNING "clang-format-10 not found, skipping")
function(aktualizr_clang_format)
endfunction()
endif()
Expand All @@ -281,7 +281,7 @@ if(CLANG_TIDY)
endforeach()
endfunction()
else()
message(WARNING "clang-tidy-8 not found, skipping")
message(WARNING "clang-tidy-10 not found, skipping")
function(aktualizr_clang_tidy)
endfunction()
endif()
Expand Down Expand Up @@ -398,7 +398,7 @@ set(GOOGLE_TEST_OUTPUT --gtest_output=xml:${CMAKE_BINARY_DIR}/results/)
# integrate with.
execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/scripts/amalgamate-jsoncpp.sh ${CMAKE_CURRENT_SOURCE_DIR}/third_party/jsoncpp ${CMAKE_CURRENT_BINARY_DIR}/jsoncpp)
include_directories(${PROJECT_BINARY_DIR}/jsoncpp)
set_source_files_properties(${PROJECT_BINARY_DIR}/jsoncpp/jsoncpp.cc PROPERTIES COMPILE_FLAGS "-Wno-float-equal -Wno-switch-default -Wno-implicit-fallthrough")
set_source_files_properties(${PROJECT_BINARY_DIR}/jsoncpp/jsoncpp.cc PROPERTIES COMPILE_FLAGS "-Wno-error")
add_library(jsoncpp OBJECT ${PROJECT_BINARY_DIR}/jsoncpp/jsoncpp.cc)

add_subdirectory("fuzz")
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The default versions packaged in recent Debian/Ubuntu releases are generally new
Additional packages are used for non-essential components:

* To build the test suite, you will need `net-tools python3-dev python3-openssl python3-venv sqlite3 valgrind`.
* To run the linting tools, you will need `clang clang-format-8 clang-tidy-8`.
* To run the linting tools, you will need `clang clang-format-10 clang-tidy-10`.
* To build additional documentation, you will need `doxygen graphviz`.
* To build with code coverage, you will need `lcov`.

Expand Down
28 changes: 14 additions & 14 deletions ci/gitlab/.gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ stages:
variables:
UBUNTU_BIONIC_MASTER_IMAGE: ${CI_REGISTRY_IMAGE}:ci-master-UBUNTU_BIONIC
UBUNTU_XENIAL_MASTER_IMAGE: ${CI_REGISTRY_IMAGE}:ci-master-UBUNTU_XENIAL
DEBIAN_TESTING_MASTER_IMAGE: ${CI_REGISTRY_IMAGE}:ci-master-DEBIAN_TESTING
UBUNTU_FOCAL_MASTER_IMAGE: ${CI_REGISTRY_IMAGE}:ci-master-UBUNTU_FOCAL
UBUNTU_BIONIC_MASTER_INSTALLIMAGE: ${CI_REGISTRY_IMAGE}:ci-install-master-UBUNTU_BIONIC
UBUNTU_XENIAL_MASTER_INSTALLIMAGE: ${CI_REGISTRY_IMAGE}:ci-install-master-UBUNTU_XENIAL
UBUNTU_BIONIC_PR_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${CI_COMMIT_REF_SLUG}-UBUNTU_BIONIC
UBUNTU_XENIAL_PR_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${CI_COMMIT_REF_SLUG}-UBUNTU_XENIAL
DEBIAN_TESTING_PR_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${CI_COMMIT_REF_SLUG}-DEBIAN_TESTING
UBUNTU_FOCAL_PR_IMAGE: ${CI_REGISTRY_IMAGE}:ci-${CI_COMMIT_REF_SLUG}-UBUNTU_FOCAL
UBUNTU_BIONIC_PR_INSTALLIMAGE: ${CI_REGISTRY_IMAGE}:ci-install-${CI_COMMIT_REF_SLUG}-UBUNTU_BIONIC
UBUNTU_XENIAL_PR_INSTALLIMAGE: ${CI_REGISTRY_IMAGE}:ci-install-${CI_COMMIT_REF_SLUG}-UBUNTU_XENIAL

Expand Down Expand Up @@ -58,9 +58,9 @@ Docker Setup:
- docker build --pull --cache-from "$UBUNTU_XENIAL_MASTER_IMAGE" --cache-from "$UBUNTU_XENIAL_PR_IMAGE" -f "$CI_PROJECT_DIR/docker/Dockerfile.ubuntu.xenial" -t "$UBUNTU_XENIAL_PR_IMAGE" .
- docker push "$UBUNTU_XENIAL_PR_IMAGE"

- docker pull "$DEBIAN_TESTING_PR_IMAGE" || docker pull "$DEBIAN_TESTING_MASTER_IMAGE" || true
- docker build --pull --cache-from "$DEBIAN_TESTING_MASTER_IMAGE" --cache-from "$DEBIAN_TESTING_PR_IMAGE" -f "$CI_PROJECT_DIR/docker/Dockerfile.debian.testing" -t "$DEBIAN_TESTING_PR_IMAGE" .
- docker push "$DEBIAN_TESTING_PR_IMAGE"
- docker pull "$UBUNTU_FOCAL_PR_IMAGE" || docker pull "$UBUNTU_FOCAL_MASTER_IMAGE" || true
- docker build --pull --cache-from "$UBUNTU_FOCAL_MASTER_IMAGE" --cache-from "$UBUNTU_FOCAL_PR_IMAGE" -f "$CI_PROJECT_DIR/docker/Dockerfile.ubuntu.focal" -t "$UBUNTU_FOCAL_PR_IMAGE" .
- docker push "$UBUNTU_FOCAL_PR_IMAGE"

# used for install tests
- docker pull "$UBUNTU_BIONIC_PR_INSTALLIMAGE" || docker pull "$UBUNTU_BIONIC_MASTER_INSTALLIMAGE" || true
Expand Down Expand Up @@ -122,12 +122,12 @@ nop11:
script:
- ./scripts/test.sh

debian-build+static:
focal-build-static:
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/aktualizr-debian-$CI_JOB_ID
GIT_CLONE_PATH: $CI_BUILDS_DIR/aktualizr-focal-build-static-$CI_JOB_ID
GIT_SUBMODULE_STRATEGY: 'recursive'

TEST_BUILD_DIR: 'build-debian-testing'
TEST_BUILD_DIR: 'build-ubuntu-focal'
TEST_CC: 'clang'
# should run with valgrind but some leaks are still unfixed
# TEST_CMAKE_BUILD_TYPE = 'Valgrind'
Expand All @@ -136,7 +136,7 @@ debian-build+static:
TEST_WITH_STATICTESTS: '1'
TEST_WITH_LOAD_TESTS: '1'
TEST_WITH_DOCS: '1'
image: "$DEBIAN_TESTING_PR_IMAGE"
image: "$UBUNTU_FOCAL_PR_IMAGE"
stage: test
except:
- /^20\d\d\.\d\d?-docs$/
Expand All @@ -147,12 +147,12 @@ debian-build+static:
- ccache/
artifacts:
paths:
- build-debian-testing/docs/doxygen/
- build-ubuntu-focal/docs/doxygen/
reports:
junit: build-debian-testing/report.xml
junit: build-ubuntu-focal/report.xml
script:
- ./scripts/test.sh
- xsltproc -o build-debian-testing/report.xml ./third_party/junit/ctest2junit.xsl build-debian-testing/Testing/**/Test.xml > /dev/null
- xsltproc -o build-ubuntu-focal/report.xml ./third_party/junit/ctest2junit.xsl build-ubuntu-focal/Testing/**/Test.xml > /dev/null

bionic-pkg:
variables:
Expand Down Expand Up @@ -301,7 +301,7 @@ github-release:
dependencies:
- bionic-pkg
- xenial-pkg
- debian-build+static # for doxygen
- focal-build-static # for doxygen
script:
# github release
- ./scripts/make_src_archive.sh ./aktualizr_src-$CI_COMMIT_TAG.tar.gz
Expand All @@ -320,7 +320,7 @@ github-release:
except:
- /^20\d\d\.\d\d?-docs$/
variables:
DOX_DOCS: 'build-debian-testing/docs/doxygen/html'
DOX_DOCS: 'build-ubuntu-focal/docs/doxygen/html'
TEST_BUILD_DIR: 'build-gh-rls'

# -- publish coverage results on gitlab pages
Expand Down
Loading

0 comments on commit 8316765

Please sign in to comment.