Skip to content

Commit

Permalink
Initial commit of clang tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
SalusaSecondus committed Apr 13, 2022
1 parent 6f7d467 commit b1c3e3a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
BasedOnStyle: WebKit
---
Language: Cpp
AlignConsecutiveMacros: true
AlignOperands: Align
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
BinPackParameters: false
ColumnLimit: 120
IncludeCategories:
- Regex: '^<openssl/'
Priority: 2
SortPriority: 0
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 3
SortPriority: 0
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 4
SortPriority: 0
- Regex: '.*'
Priority: 1
SortPriority: 0
MaxEmptyLinesToKeep: 3
WhitespaceSensitiveMacros:
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- TO_STRING
- TO_STRING_0
- CONCAT2
- CONCAT2_INTERNAL
...

4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Current values are:
* `ALL` - Enables all of the above
(May still require changes to your logging configuration to see the new logs.)
* Enables skipping the bundled lib by setting the system property `com.amazon.corretto.crypto.provider.useExternalLib` [PR #168](https://github.com/corretto/amazon-corretto-crypto-provider/pull/168)
* Allows developers to run `clang-tidy` against the source by passing `-DUSE_CLANG_TIDY=true` to gradlew.
Example: `./gradlew -DUSE_CLANG_TIDY=true build`
This may require deleting `build/cmake` prior to running.
[PR #191](https://github.com/corretto/amazon-corretto-crypto-provider/pull/191)

### Patches
* Improve zeroization of DRBG output. [PR #162](https://github.com/corretto/amazon-corretto-crypto-provider/pull/162)
Expand Down
23 changes: 23 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@ set(FORCE_DISABLE_RDRAND NO CACHE BOOL "Force CPUID detection of rdrand support
set(TEST_DATA_DIR ${PROJECT_SOURCE_DIR}/test-data/ CACHE STRING "Path to directory containing test data")
set(ORIG_SRCROOT ${PROJECT_SOURCE_DIR} CACHE STRING "Path to root of original package")
set(PROVIDER_VERSION_STRING "" CACHE STRING "X.Y.Z formatted version of the provider")
if (USE_CLANG_TIDY)
# https://releases.llvm.org/9.0.0/tools/clang/tools/extra/docs/clang-tidy/checks/list.html
# https://clang.llvm.org/extra/clang-tidy/#suppressing-undesired-diagnostics
# TODO: Make this enforcing with "-warnings-as-errors=*;" once we're happy with the state
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-checks=-*")
# Categories we want
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},bugprone-*)
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},cert-*)
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},cppcoreguidelines-*)
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},clang-analyzer-*)
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},performance-*)
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},portability-*)
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},readability-*)

# Things we don't want
# We must use reinterpret cast to move things across the JNI boundary
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},-cppcoreguidelines-pro-type-reinterpret-cast)
# We intentionally omit the parameters for jclass
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},-readability-named-parameter)
# We target older styles of C++. We can revisit these after checking all build chains
set(CMAKE_CXX_CLANG_TIDY ${CMAKE_CXX_CLANG_TIDY},-cppcoreguidelines-macro-usage)
# Anything referencing gsl:: (Guidelines support library) is too new for us
endif()

if (NOT DEFINED JACOCO_AGENT_JAR)
set(JACOCO_AGENT_JAR ${JACOCO_ROOT}/jacocoagent.jar)
Expand Down
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,13 @@ task executeCmake(type: Exec) {
if (System.properties['TEST_JAVA_MAJOR_VERSION'] != null) {
args '-DTEST_JAVA_MAJOR_VERSION=' + System.properties['TEST_JAVA_MAJOR_VERSION']
}

if (System.properties['SINGLE_TEST'] != null) {
args '-DSINGLE_TEST=' + System.properties['SINGLE_TEST']

}
if (System.properties['USE_CLANG_TIDY'] != null) {
args '-DUSE_CLANG_TIDY=' + System.properties['USE_CLANG_TIDY']

}
args projectDir
}
Expand Down

0 comments on commit b1c3e3a

Please sign in to comment.