Skip to content

Commit c7cc502

Browse files
clippy: added clippy checks
Addresses: eclipse-score/score#2008 Signed-off-by: Dan Calavrezo <[email protected]>
1 parent 8d4ef3b commit c7cc502

File tree

7 files changed

+59
-3
lines changed

7 files changed

+59
-3
lines changed

.bazelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ common --registry=https://raw.githubusercontent.com/eclipse-score/bazel_registry
1515
common --registry=https://bcr.bazel.build
1616

1717

18+
# Clippy linting (enabled by default)
19+
build --aspects=@rules_rust//rust:defs.bzl%rust_clippy_aspect
20+
build --output_groups=+clippy_checks
21+
build --@rules_rust//rust/settings:clippy.toml=@score_rust_policies//clippy/strict:clippy.toml
22+
1823
# Flags needed by score_baselibs and communication modules.
1924
# Do not add more!
2025
build --@score_baselibs//score/mw/log/detail/flags:KUse_Stub_Implementation_Only=False

.github/workflows/bazel_clippy.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2025 Contributors to the Eclipse Foundation
3+
#
4+
# See the NOTICE file(s) distributed with this work for additional
5+
# information regarding copyright ownership.
6+
#
7+
# This program and the accompanying materials are made available under the
8+
# terms of the Apache License Version 2.0 which is available at
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# SPDX-License-Identifier: Apache-2.0
12+
# *******************************************************************************
13+
name: Bazel Clippy
14+
15+
on:
16+
pull_request:
17+
types: [opened, reopened, synchronize]
18+
push:
19+
branches:
20+
- main
21+
merge_group:
22+
types: [checks_requested]
23+
24+
jobs:
25+
bazel-clippy:
26+
uses: eclipse-score/cicd-workflows/.github/workflows/static-analysis.yml@main
27+
with:
28+
bazel-target: "build //:clippy"

BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# *******************************************************************************
1313

1414
load("@score_docs_as_code//:docs.bzl", "docs")
15+
load("@rules_rust//rust:defs.bzl", "rust_clippy")
1516

1617
docs(
1718
data = [
@@ -30,3 +31,15 @@ filegroup(
3031
srcs = ["README.md"],
3132
visibility = ["//visibility:public"],
3233
)
34+
35+
rust_clippy(
36+
name = "clippy",
37+
testonly = True,
38+
tags = ["manual"],
39+
visibility = ["//visibility:public"],
40+
deps = [
41+
"//feature_integration_tests/rust_test_scenarios:rust_test_scenarios",
42+
"//feature_showcase/rust:kyron_example",
43+
"//feature_showcase/rust:orch_per_example",
44+
],
45+
)

MODULE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,6 @@ git_override(
6464

6565
# imports for the feature showcase module
6666
bazel_dep(name = "rules_rust", version = "0.61.0")
67+
bazel_dep(name = "score_rust_policies", version = "0.0.2", dev_dependency = True)
6768
bazel_dep(name = "score_itf", version = "0.1.0")
6869
bazel_dep(name = "score_crates", version = "0.0.4")

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ bazel build --config bl-x86_64-linux \
4646
bazel build --config bl-x86_64-linux @score_orchestrator//src/...
4747
```
4848

49+
## Clippy
50+
51+
- Clippy runs by default via `.bazelrc` on all Rust targets (Rust tests may be tagged `no-clippy`).
52+
- Use `bazel build //:clippy` if you want an explicit lint-only target, or build the Rust targets normally to see Clippy diagnostics.
53+
- The Clippy config comes from `@score_rust_policies//clippy/strict:clippy.toml`.
54+
4955
## Feature showcase examples
5056
The examples that are aiming to showcase features provided by S-CORE are located in `feature_showcase` folder.
5157
You can run them currently for host platform using `--config bl-x86_64-linux`.

feature_integration_tests/rust_test_scenarios/BUILD

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ load("@rules_rust//rust:defs.bzl", "rust_binary")
1616
rust_binary(
1717
name = "rust_test_scenarios",
1818
srcs = glob(["src/**/*.rs"]),
19-
visibility = ["//feature_integration_tests/python_test_cases:__pkg__"],
19+
visibility = [
20+
"//feature_integration_tests/python_test_cases:__pkg__",
21+
"//visibility:public",
22+
],
2023
tags = [
2124
"manual",
2225
],
@@ -31,4 +34,4 @@ rust_binary(
3134
"@score_crates//:serde",
3235
"@score_crates//:serde_json",
3336
],
34-
)
37+
)

feature_integration_tests/rust_test_scenarios/src/scenarios/basic/orchestration_with_persistency.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async fn kvs_save_cycle_number(path: String) -> Result<(), UserErrValue> {
8787

8888
// Simple set/get.
8989
let key = "run_cycle_number";
90-
let last_cycle_number: u32 = kvs.get_value_as::<u32>(key).unwrap_or_else(|_| 0_u32);
90+
let last_cycle_number: u32 = kvs.get_value_as::<u32>(key).unwrap_or(0_u32);
9191

9292
kvs.set_value(key, last_cycle_number + 1)
9393
.expect("Failed to set value");

0 commit comments

Comments
 (0)