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 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/setup-ci/action.yaml b/.trunk/setup-ci/action.yaml new file mode 100644 index 000000000..a4c59fb70 --- /dev/null +++ b/.trunk/setup-ci/action.yaml @@ -0,0 +1,27 @@ +name: Trunk Check setup +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: | + cd .. + git clone https://github.com/EVerest/everest-cmake + - 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 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 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());