From 98204babd54e7632ef0f28db478b8384082f3960 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Fri, 10 Nov 2023 14:39:50 +0100 Subject: [PATCH 1/7] activated sharing of `.trunk` via Trunk extension Signed-off-by: Dominik K --- .trunk/.gitignore | 8 ++++++ .trunk/configs/.isort.cfg | 2 ++ .trunk/configs/.markdownlint.yaml | 10 ++++++++ .trunk/configs/.shellcheckrc | 7 ++++++ .trunk/configs/.yamllint.yaml | 10 ++++++++ .trunk/configs/ruff.toml | 5 ++++ .trunk/trunk.yaml | 41 +++++++++++++++++++++++++++++++ 7 files changed, 83 insertions(+) create mode 100644 .trunk/.gitignore create mode 100644 .trunk/configs/.isort.cfg create mode 100644 .trunk/configs/.markdownlint.yaml create mode 100644 .trunk/configs/.shellcheckrc create mode 100644 .trunk/configs/.yamllint.yaml create mode 100644 .trunk/configs/ruff.toml create mode 100644 .trunk/trunk.yaml diff --git a/.trunk/.gitignore b/.trunk/.gitignore new file mode 100644 index 000000000..1e2465290 --- /dev/null +++ b/.trunk/.gitignore @@ -0,0 +1,8 @@ +*out +*logs +*actions +*notifications +*tools +plugins +user_trunk.yaml +user.yaml diff --git a/.trunk/configs/.isort.cfg b/.trunk/configs/.isort.cfg new file mode 100644 index 000000000..b9fb3f3e8 --- /dev/null +++ b/.trunk/configs/.isort.cfg @@ -0,0 +1,2 @@ +[settings] +profile=black diff --git a/.trunk/configs/.markdownlint.yaml b/.trunk/configs/.markdownlint.yaml new file mode 100644 index 000000000..fb940393d --- /dev/null +++ b/.trunk/configs/.markdownlint.yaml @@ -0,0 +1,10 @@ +# Autoformatter friendly markdownlint config (all formatting rules disabled) +default: true +blank_lines: false +bullet: false +html: false +indentation: false +line_length: false +spaces: false +url: false +whitespace: false diff --git a/.trunk/configs/.shellcheckrc b/.trunk/configs/.shellcheckrc new file mode 100644 index 000000000..8c7b1ada8 --- /dev/null +++ b/.trunk/configs/.shellcheckrc @@ -0,0 +1,7 @@ +enable=all +source-path=SCRIPTDIR +disable=SC2154 + +# If you're having issues with shellcheck following source, disable the errors via: +# disable=SC1090 +# disable=SC1091 diff --git a/.trunk/configs/.yamllint.yaml b/.trunk/configs/.yamllint.yaml new file mode 100644 index 000000000..4d444662d --- /dev/null +++ b/.trunk/configs/.yamllint.yaml @@ -0,0 +1,10 @@ +rules: + quoted-strings: + required: only-when-needed + extra-allowed: ["{|}"] + empty-values: + forbid-in-block-mappings: true + forbid-in-flow-mappings: true + key-duplicates: {} + octal-values: + forbid-implicit-octal: true diff --git a/.trunk/configs/ruff.toml b/.trunk/configs/ruff.toml new file mode 100644 index 000000000..f5a235cf9 --- /dev/null +++ b/.trunk/configs/ruff.toml @@ -0,0 +1,5 @@ +# Generic, formatter-friendly config. +select = ["B", "D3", "E", "F"] + +# Never enforce `E501` (line length violations). This should be handled by formatters. +ignore = ["E501"] diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml new file mode 100644 index 000000000..260f19e61 --- /dev/null +++ b/.trunk/trunk.yaml @@ -0,0 +1,41 @@ +# This file controls the behavior of Trunk: https://docs.trunk.io/cli +# To learn more about the format of this file, see https://docs.trunk.io/reference/trunk-yaml +version: 0.1 +cli: + version: 1.17.2 +plugins: + sources: + - id: trunk + ref: v1.2.6 + uri: https://github.com/trunk-io/plugins +runtimes: + enabled: + - go@1.21.0 + - node@18.12.1 + - python@3.10.8 +lint: + enabled: + - taplo@0.8.1 + - clang-tidy@16.0.3 + - actionlint@1.6.26 + - bandit@1.7.5 + - black@23.10.0 + - checkov@3.0.32 + - clang-format@16.0.3 + - git-diff-check + - isort@5.12.0 + - markdownlint@0.37.0 + - prettier@3.0.3 + - ruff@0.1.5 + - shellcheck@0.9.0 + - shfmt@3.6.0 + - trivy@0.47.0 + - trufflehog@3.62.1 + - yamllint@1.33.0 +actions: + disabled: + - trunk-announce + - trunk-check-pre-push + - trunk-fmt-pre-commit + enabled: + - trunk-upgrade-available From e79bddc265d5a227ea9e6ca419c34aaa77bd74ef Mon Sep 17 00:00:00 2001 From: Dominik K Date: Fri, 10 Nov 2023 14:52:36 +0100 Subject: [PATCH 2/7] add `.clang-tidy` with all checks activated Signed-off-by: Dominik K --- .clang-tidy | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 000000000..707d52c2c --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,43 @@ +Checks: >- + * + - llvmlibc-callee-namespace # + # bugprone-*, + # cppcoreguidelines-*, + # google-*, + # misc-*, + # modernize-*, + # performance-*, + # readability-*, + # -bugprone-lambda-function-name, + # -bugprone-reserved-identifier, + # -cppcoreguidelines-avoid-goto, + # -cppcoreguidelines-avoid-magic-numbers, + # -cppcoreguidelines-avoid-non-const-global-variables, + # -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + # -cppcoreguidelines-pro-type-vararg, + # -google-readability-braces-around-statements, + # -google-readability-function-size, + # -misc-no-recursion, + # -modernize-return-braced-init-list, + # -modernize-use-nodiscard, + # -modernize-use-trailing-return-type, + # -performance-unnecessary-value-param, + # -readability-magic-numbers, + +CheckOptions: + - key: readability-function-cognitive-complexity.Threshold + value: 100 + - key: readability-function-cognitive-complexity.IgnoreMacros + value: true + # Set naming conventions for your style below (there are dozens of naming settings possible): + # See https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html + - key: readability-identifier-naming.EnumConstantCase + value: UPPER_CASE + # - key: readability-identifier-naming.ClassCase + # value: CamelCase + # - key: readability-identifier-naming.NamespaceCase + # value: lower_case + # - key: readability-identifier-naming.PrivateMemberSuffix + # value: _ + # - key: readability-identifier-naming.StructCase + # value: CamelCase From f8109205c8aa00b902cffd129e00c9bd54bf3fe1 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Fri, 10 Nov 2023 14:54:52 +0100 Subject: [PATCH 3/7] add code-line which should trigger clang-tidy warnings Signed-off-by: Dominik K --- lib/ocpp/v16/charge_point_impl.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index f584c2520..fb7a66815 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -275,6 +275,9 @@ void ChargePointImpl::clock_aligned_meter_values_sample() { for (int32_t connector = 1; connector < this->configuration->getNumberOfConnectors() + 1; connector++) { auto meter_value = this->get_latest_meter_value( connector, this->configuration->getMeterValuesAlignedDataVector(), ReadingContext::Sample_Clock); + + meter_value.value(); // <- this should trigger multiple clang-tidy warnings + if (meter_value.has_value()) { if (this->transaction_handler->transaction_active(connector)) { this->transaction_handler->get_transaction(connector)->add_meter_value(meter_value.value()); From 6c72462d8ffb55ca839a479eed0daa340861d936 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Fri, 10 Nov 2023 15:08:25 +0100 Subject: [PATCH 4/7] add Trunk Check setup Signed-off-by: Dominik K --- .trunk/setup-ci/action.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .trunk/setup-ci/action.yaml diff --git a/.trunk/setup-ci/action.yaml b/.trunk/setup-ci/action.yaml new file mode 100644 index 000000000..927cf8a0b --- /dev/null +++ b/.trunk/setup-ci/action.yaml @@ -0,0 +1,18 @@ +name: Trunk Check setup +description: Set up dependencies for Trunk Check + +runs: + using: composite + steps: + - name: Run cmake + shell: bash + run: | + cmake -B build/ \ + -D CMAKE_CXX_COMPILER=clang++-15 -D CXX_STANDARD=17 \ + -D CMAKE_EXPORT_COMPILE_COMMANDS=1 \ + -D CMAKE_BUILD_TYPE=Debug \ + -D CMAKE_GENERATOR="Unix Makefiles" + + - name: Run make + shell: bash + run: make -j$(nproc) install From 807a9de0be0d2f41e059280d572b29cd1dae1bbc Mon Sep 17 00:00:00 2001 From: Dominik K Date: Fri, 10 Nov 2023 15:16:34 +0100 Subject: [PATCH 5/7] setup action: clone `everest-cmake` Signed-off-by: Dominik K --- .trunk/setup-ci/action.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.trunk/setup-ci/action.yaml b/.trunk/setup-ci/action.yaml index 927cf8a0b..7030fbef6 100644 --- a/.trunk/setup-ci/action.yaml +++ b/.trunk/setup-ci/action.yaml @@ -4,6 +4,10 @@ description: Set up dependencies for Trunk Check runs: using: composite steps: + - name: Checkout `everest-cmake` + run: | + cd .. + git clone https://github.com/EVerest/everest-cmake - name: Run cmake shell: bash run: | From bec49fab147a50d4a27939656f33b7167f285c8f Mon Sep 17 00:00:00 2001 From: Dominik K Date: Fri, 10 Nov 2023 15:18:07 +0100 Subject: [PATCH 6/7] `shell:` is a required property Signed-off-by: Dominik K --- .trunk/setup-ci/action.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.trunk/setup-ci/action.yaml b/.trunk/setup-ci/action.yaml index 7030fbef6..597b06de4 100644 --- a/.trunk/setup-ci/action.yaml +++ b/.trunk/setup-ci/action.yaml @@ -5,6 +5,7 @@ runs: using: composite steps: - name: Checkout `everest-cmake` + shell: bash run: | cd .. git clone https://github.com/EVerest/everest-cmake From 3ab18c2c3dc335565991c153330381661d8ba970 Mon Sep 17 00:00:00 2001 From: Dominik K Date: Fri, 10 Nov 2023 15:46:01 +0100 Subject: [PATCH 7/7] install big dependencies Signed-off-by: Dominik K --- .trunk/setup-ci/action.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.trunk/setup-ci/action.yaml b/.trunk/setup-ci/action.yaml index 597b06de4..a4c59fb70 100644 --- a/.trunk/setup-ci/action.yaml +++ b/.trunk/setup-ci/action.yaml @@ -4,6 +4,10 @@ description: Set up dependencies for Trunk Check runs: using: composite steps: + - name: Install big dependencies + shell: bash + run: | + apt install libboost-all-dev libssl-dev libsqlite3-dev - name: Checkout `everest-cmake` shell: bash run: |