Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,9 @@ coverage --combined_report=lcov
coverage --test_env=COVERAGE_GCOV_OPTIONS=-bcu
coverage --features=coverage
coverage --cache_test_results=no

# Clang-tidy: bazel test --config=clang-tidy //...
test:clang-tidy --aspects=//tools/lint:linters.bzl%clang_tidy_aspect
test:clang-tidy --output_groups=+rules_lint_report
test:clang-tidy --extra_toolchains=@llvm_toolchain//:cc-toolchain-x86_64-linux
test:clang-tidy --extra_toolchains=@score_toolchains_rust//toolchains/ferrocene:ferrocene_x86_64_unknown_linux_gnu
33 changes: 33 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# *******************************************************************************
# Copyright (c) 2026 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
# *******************************************************************************

# Clang-tidy configuration for score_logging.
Checks: >-
-*,
clang-analyzer-*,
cert-*,
cppcoreguidelines-*,
bugprone-*,
misc-*,
performance-*,
readability-*,
modernize-*

# NOTE: WarningsAsErrors is yet subject to be expanded per module as compliance increases.
WarningsAsErrors: >-
clang-analyzer-*

# Exclude third-party, generated, and external-repo headers from analysis.
HeaderFilterRegex: '^(?!.*/(third_party|external|bazel-out)/).*$'

FormatStyle: file
44 changes: 44 additions & 0 deletions .github/workflows/clang_tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# *******************************************************************************
# 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: Clang-Tidy

on:
pull_request:
types: [opened, reopened, synchronize]
merge_group:

permissions:
contents: read

concurrency:
group: clang-tidy-${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
clang-tidy:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- name: Setup Bazel
uses: bazel-contrib/setup-bazel@0.15.0
with:
bazelisk-version: 1.26.0
disk-cache: clang-tidy
repository-cache: true
external-cache: true
- name: Run clang-tidy
# Scope limited to //score/mw/... because Rust/QNX targets are not yet
# validated against this configuration. Expand once they pass.
run: bazel test --config=clang-tidy --lockfile_mode=error //score/mw/...
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ use_format_targets()

exports_files([
"MODULE.bazel",
".clang-tidy",
])

# Creates all documentation targets:
Expand Down
23 changes: 22 additions & 1 deletion MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,18 @@ bazel_dep(name = "rules_python", version = "1.4.1")
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "rules_rust", version = "0.68.1-score")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "aspect_rules_lint", version = "1.0.3")
bazel_dep(name = "aspect_rules_lint", version = "2.5.0")

bazel_dep(name = "score_cpp_policies", version = "0.0.0", dev_dependency = True)
git_override(
module_name = "score_cpp_policies",
# TODO: replace with merged commit on eclipse-score/score_cpp_policies once PR #2 lands.
commit = "f147fc8",
remote = "https://github.com/RSingh1511/score_cpp_policies.git",
)

bazel_dep(name = "toolchains_llvm", version = "1.5.0", dev_dependency = True)

bazel_dep(name = "buildifier_prebuilt", version = "7.3.1")
bazel_dep(name = "platforms", version = "1.0.0")

Expand Down Expand Up @@ -85,6 +96,16 @@ use_repo(
"score_qcc_x86_64_toolchain",
)

llvm = use_extension(
"@toolchains_llvm//toolchain/extensions:llvm.bzl",
"llvm",
dev_dependency = True,
)
llvm.toolchain(
llvm_version = "19.1.7",
)
use_repo(llvm, "llvm_toolchain")

PYTHON_VERSION = "3.12"

python = use_extension("@rules_python//python/extensions:python.bzl", "python", dev_dependency = True)
Expand Down
318 changes: 201 additions & 117 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion score/mw/log/detail/common/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,14 @@ cc_test(
srcs = [
"@score_baselibs//score/mw/log:log_stream_test.cpp",
],
copts = ["-Wno-deprecated-declarations"], # src from @score_baselibs uses deprecated APIs
features = COMPILER_WARNING_FEATURES + [
"aborts_upon_exception",
],
tags = ["unit"],
tags = [
"no-clang-tidy", # src from @score_baselibs, cannot suppress deprecations in source
"unit",
],
deps = [
"@googletest//:gtest_main",
"@score_baselibs//score/mw/log:console",
Expand Down
2 changes: 0 additions & 2 deletions score/mw/log/detail/common/helper_functions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
#include "score/mw/log/detail/common/helper_functions.h"
#include <tuple>

#include "gtest/gtest.h"

Expand All @@ -20,7 +19,6 @@ namespace helper
using testing::Types;
TEST(SumTest, SumNoOverflow)
{
std::numeric_limits<std::size_t>::max();
const std::size_t expected_value = 6U;
std::size_t result = Sum<uint8_t>(1U, 2U, 3U);
EXPECT_EQ(result, expected_value);
Expand Down
17 changes: 17 additions & 0 deletions tools/lint/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# *******************************************************************************
# 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
# *******************************************************************************

exports_files(
["linters.bzl"],
visibility = ["//visibility:public"],
)
23 changes: 23 additions & 0 deletions tools/lint/linters.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# *******************************************************************************
# 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
# *******************************************************************************

"""Clang-tidy linter configuration for score_logging."""

load("@score_cpp_policies//clang_tidy:defs.bzl", "make_clang_tidy_aspect", "make_clang_tidy_test")

clang_tidy_aspect = make_clang_tidy_aspect(
binary = Label("@llvm_toolchain//:clang-tidy"),
configs = [Label("//:.clang-tidy")],
)

clang_tidy_test = make_clang_tidy_test(aspect = clang_tidy_aspect)
Loading