From 0db660bb8f2bf756732dd750966065c578715784 Mon Sep 17 00:00:00 2001 From: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com> Date: Wed, 4 Feb 2026 16:59:31 +0200 Subject: [PATCH 1/2] clippy: integrated clippy using rules_lint incorporated in the .bazelrc added new workflow Signed-off-by: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com> --- .bazelrc | 5 ++++ .github/workflows/clippy.yml | 28 +++++++++++++++++++ MODULE.bazel | 3 +- README.md | 7 +++++ .../com-api/com-api-runtime-lola/runtime.rs | 27 ++++++++++-------- 5 files changed, 57 insertions(+), 13 deletions(-) create mode 100644 .github/workflows/clippy.yml diff --git a/.bazelrc b/.bazelrc index cd00881e..be8fe039 100644 --- a/.bazelrc +++ b/.bazelrc @@ -70,6 +70,11 @@ coverage --test_env=LLVM_PROFILE_CONTINUOUS_MODE=1 coverage --cxxopt -mllvm coverage --cxxopt -runtime-counter-relocation +# Clippy linting (enabled by default) +build --aspects=@score_rust_policies//clippy:linters.bzl%clippy_strict +build --output_groups=+rules_lint_human +build:lint --@aspect_rules_lint//lint:fail_on_violation=true + # Clang-tidy configuration # Run clang-tidy on all C++ targets with: bazel test --config=clang-tidy //... test:clang-tidy --aspects=//:tools/lint/linters.bzl%clang_tidy_aspect diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml new file mode 100644 index 00000000..e5b1de2e --- /dev/null +++ b/.github/workflows/clippy.yml @@ -0,0 +1,28 @@ +# ******************************************************************************* +# Copyright (c) 2025 Contributors to the Eclipse Foundation +# +# See the NOTICE file(s) distributed with this work for additional +# information regarding copyright ownership. +# This program and the accompanying materials are made available under the +# terms of the Apache License Version 2.0 which is available at +# https://www.apache.org/licenses/LICENSE-2.0 +# +# SPDX-License-Identifier: Apache-2.0 +# ******************************************************************************* +name: Bazel Clippy + +on: + pull_request: + types: [opened, reopened, synchronize] + push: + branches: + - main + merge_group: + types: [checks_requested] + +jobs: + bazel-clippy: + uses: eclipse-score/cicd-workflows/.github/workflows/static-analysis.yml@dcalavrezo_clippy_1 + with: + bazel-targets: "//..." + bazel-config: "lint" diff --git a/MODULE.bazel b/MODULE.bazel index 0c70dc6c..13e1f158 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -92,10 +92,11 @@ download_file( urls = ["https://github.com/muttleyxd/clang-tools-static-binaries/releases/download/master-2da3e7b/clang-format-19_linux-amd64"], ) -bazel_dep(name = "aspect_rules_lint", version = "1.13.0") +bazel_dep(name = "aspect_rules_lint", version = "2.0.0") bazel_dep(name = "googletest", version = "1.17.0.bcr.2") bazel_dep(name = "google_benchmark", version = "1.9.4") bazel_dep(name = "rules_rust", version = "0.61.0") +bazel_dep(name = "score_rust_policies", version = "0.0.4", dev_dependency = True) bazel_dep(name = "score_toolchains_rust", version = "0.2.0", dev_dependency = True) git_override( diff --git a/README.md b/README.md index c371e059..8697b2be 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,13 @@ bazel test //... bazel build //score/mw/com:all ``` +## Clippy + +- Clippy runs by default via `.bazelrc` when building Rust targets (rules_lint aspect). +- Use `bazel build //score/mw/com/...` (or any Rust target pattern) while developing. +- Use `bazel build --config=lint //score/mw/com/...` to enable lint config, including `--@aspect_rules_lint//lint:fail_on_violation=true`. +- The Clippy config comes from `@score_rust_policies//clippy/strict:clippy.toml`. + ## Project Structure ``` diff --git a/score/mw/com/impl/rust/com-api/com-api-runtime-lola/runtime.rs b/score/mw/com/impl/rust/com-api/com-api-runtime-lola/runtime.rs index 8d13df30..8144af17 100644 --- a/score/mw/com/impl/rust/com-api/com-api-runtime-lola/runtime.rs +++ b/score/mw/com/impl/rust/com-api/com-api-runtime-lola/runtime.rs @@ -358,12 +358,12 @@ impl<'a, T> SampleMaybeUninit<'a, T> where T: CommData, { - fn get_allocatee_data_ptr(&self) -> Option<&mut core::mem::MaybeUninit> { + fn get_allocatee_data_ptr(&mut self) -> Option<&mut core::mem::MaybeUninit> { //SAFETY: allocatee_ptr is valid which is created using get_allocatee_ptr() and // it will be again type casted to T type pointer in cpp side so valid to send as void pointer let data_ptr = unsafe { generic_bridge_ffi_rs::get_allocatee_data_ptr( - std::ptr::from_ref(self.allocatee_ptr.as_ref()) as *const std::ffi::c_void, + std::ptr::from_mut(&mut (*self.allocatee_ptr.inner)) as *mut std::ffi::c_void, T::ID, ) as *mut core::mem::MaybeUninit }; @@ -378,17 +378,20 @@ where type SampleMut = SampleMut<'a, T>; fn write(self, val: T) -> SampleMut<'a, T> { - let data_ptr = self - .get_allocatee_data_ptr() - .expect("Allocatee data pointer is null"); - - //It is safe to write the value because data_ptr is valid - // and we are writing the value of type T which is same as allocatee_ptr type - data_ptr.write(val); + let mut this = self; + { + let data_ptr = this + .get_allocatee_data_ptr() + .expect("Allocatee data pointer is null"); + + //It is safe to write the value because data_ptr is valid + // and we are writing the value of type T which is same as allocatee_ptr type + data_ptr.write(val); + } SampleMut { - skeleton_event: self.skeleton_event, - allocatee_ptr: self.allocatee_ptr, + skeleton_event: this.skeleton_event, + allocatee_ptr: this.allocatee_ptr, lifetime: PhantomData, } } @@ -958,7 +961,7 @@ pub struct RuntimeBuilderImpl { impl Builder for RuntimeBuilderImpl { fn build(self) -> com_api_concept::Result { - proxy_bridge_rs::initialize(self.config_path.as_ref().map(PathBuf::as_path)); + proxy_bridge_rs::initialize(self.config_path.as_deref()); Ok(LolaRuntimeImpl {}) } } From fb73289554d115d600c3f4780c5e48bb35d80a88 Mon Sep 17 00:00:00 2001 From: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com> Date: Thu, 5 Feb 2026 16:24:50 +0200 Subject: [PATCH 2/2] clippy: uplifted msrv uplifted msrv to 1.90.0 Signed-off-by: Dan Calavrezo <195309321+dcalavrezo-qorix@users.noreply.github.com> --- MODULE.bazel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MODULE.bazel b/MODULE.bazel index 13e1f158..913317f5 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -96,7 +96,7 @@ bazel_dep(name = "aspect_rules_lint", version = "2.0.0") bazel_dep(name = "googletest", version = "1.17.0.bcr.2") bazel_dep(name = "google_benchmark", version = "1.9.4") bazel_dep(name = "rules_rust", version = "0.61.0") -bazel_dep(name = "score_rust_policies", version = "0.0.4", dev_dependency = True) +bazel_dep(name = "score_rust_policies", version = "0.0.5", dev_dependency = True) bazel_dep(name = "score_toolchains_rust", version = "0.2.0", dev_dependency = True) git_override(