Skip to content

kvs: fix CodeQL MISRA C++:2023 findings - #638

Merged
PandaeDo merged 1 commit into
eclipse-score:mainfrom
qorix-group:arkjedrz_codeql-cpp-fixes
Nov 2, 2026
Merged

PandaeDo merged 1 commit into
eclipse-score:mainfrom
qorix-group:arkjedrz_codeql-cpp-fixes

Conversation

@arkjedrz

@arkjedrz arkjedrz commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

The C++ CodeQL job reports MISRA C++:2023 results for the KVS. Fix the code where a rule points at a real issue, and record a deviation for the rest.

Code changes:

  • Discard unused emplace, insert_or_assign and read results through score::cpp::ignore (Rule 0.1.2).
  • Add clarifying parentheses and use unsigned masks for the Adler-32 hash bytes (Rules 8.0.1 and 7.0.4).
  • Replace structured bindings in range-for loops with .first and .second (Rules 9.3.1, 11.6.1, 5.10.1 and 10.0.1).
  • Pass HasUniqueKeys and a new IsPrintableAscii predicate to std::all_of instead of lambdas (Rule 8.2.10).
  • Drop the comma operator from the Adler-32 loop (Rules 8.19.1 and 9.5.1).
  • Complete if-else chains and the switch in HasUniqueKeys, and hoist JSON ranges into named references (Rules 9.4.1, 9.4.2 and 9.5.2).
  • Rename snapshots through score::os::Stdio (Rule 30.0.1).
  • Ref-qualify the assignment operators of Kvs and KvsValue, and split KvsValue::GetValue into const& and && overloads (Rules 15.0.2 and 6.8.4).
  • Give KvsValue::Type the underlying type std::uint8_t (Rule 10.2.1).
  • Read character codes and hash bytes through std::char_traits::to_int_type (Rules 7.0.3 and 8.2.5).
  • Declare namespace-scope constants const instead of constexpr (Rule 4.1.2).

CI changes:

  • Add coding-standards.yaml with the remaining MISRA deviations and their justifications.
  • Index the deviations into the CodeQL database with the coding-standards scripts at v2.62.0, pinned by sha256.
  • Disapply the advisory Rule 21.6.1, as the KVS uses std::string, std::map and std::vector by design.

This changes the public API.
Assigning to an rvalue Kvs or KvsValue no longer compiles. KvsValue::GetValue on a temporary returns a value instead of a reference. The size of KvsValue::Type changes, which affects the ABI.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

License Check Results

🚀 The license check job ran with the Bazel command:

bazel run --lockfile_mode=error //:license-check

Status: ⚠️ Needs Review

Click to expand output
[License Check Output]
Starting local Bazel server (8.7.0) and connecting to it...
INFO: Invocation ID: 23153a3a-54ae-4205-a32a-d8cfc6eb8f2c
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 2 packages loaded
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Loading: 2 packages loaded
    currently loading: 
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)
Analyzing: target //:license-check (3 packages loaded, 0 targets configured)

Analyzing: target //:license-check (98 packages loaded, 14 targets configured)

Analyzing: target //:license-check (99 packages loaded, 14 targets configured)

Analyzing: target //:license-check (100 packages loaded, 14 targets configured)

Analyzing: target //:license-check (100 packages loaded, 14 targets configured)

Analyzing: target //:license-check (185 packages loaded, 3780 targets configured)

Analyzing: target //:license-check (201 packages loaded, 10824 targets configured)

Analyzing: target //:license-check (207 packages loaded, 11661 targets configured)

Analyzing: target //:license-check (207 packages loaded, 11661 targets configured)

Analyzing: target //:license-check (209 packages loaded, 11785 targets configured)

Analyzing: target //:license-check (212 packages loaded, 17774 targets configured)

INFO: Analyzed target //:license-check (213 packages loaded, 17903 targets configured).
[12 / 16] [Prepa] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes
INFO: From Generating Dash formatted dependency file ...:
INFO: Successfully converted 50 packages from Cargo.lock to bazel-out/k8-fastbuild/bin/tools/formatted.txt
[14 / 16] JavaToolchainCompileBootClasspath external/rules_java+/toolchains/platformclasspath.jar; 0s disk-cache, processwrapper-sandbox
INFO: Found 1 target...
Target //tools:license.check.license_check up-to-date:
  bazel-bin/tools/license.check.license_check
  bazel-bin/tools/license.check.license_check.jar
INFO: Elapsed time: 44.484s, Critical Path: 1.94s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/tools/license.check.license_check tools/formatted.txt <args omitted>
[main] INFO Querying Eclipse Foundation for license data for 42 items.
[main] INFO Found 32 items.
[main] INFO Querying ClearlyDefined for license data for 10 items.
[main] INFO Found 10 items.
[main] INFO License information could not be automatically verified for the following content:
[main] INFO 
[main] INFO crate/cratesio/-/lazy_static/1.5.1
[main] INFO 
[main] INFO This content is either not correctly mapped by the system, or requires review.

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Documentation preview for this pull request is available at:
pr-638: https://eclipse-score.github.io/persistency/pr-638/

The C++ CodeQL job reports MISRA C++:2023 results for the KVS.
Fix the code where a rule points at a real issue, and record a deviation for the rest.

Code changes:
- Discard unused emplace, insert_or_assign and read results through score::cpp::ignore (Rule 0.1.2).
- Add clarifying parentheses and use unsigned masks for the Adler-32 hash bytes (Rules 8.0.1 and 7.0.4).
- Replace structured bindings in range-for loops with `.first` and `.second` (Rules 9.3.1, 11.6.1, 5.10.1 and 10.0.1).
- Pass HasUniqueKeys and a new IsPrintableAscii predicate to std::all_of instead of lambdas (Rule 8.2.10).
- Drop the comma operator from the Adler-32 loop (Rules 8.19.1 and 9.5.1).
- Complete if-else chains and the switch in HasUniqueKeys, and hoist JSON ranges into named references (Rules 9.4.1, 9.4.2 and 9.5.2).
- Rename snapshots through score::os::Stdio (Rule 30.0.1).
- Ref-qualify the assignment operators of Kvs and KvsValue, and split KvsValue::GetValue into const& and && overloads (Rules 15.0.2 and 6.8.4).
- Give KvsValue::Type the underlying type std::uint8_t (Rule 10.2.1).
- Read character codes and hash bytes through std::char_traits<char>::to_int_type (Rules 7.0.3 and 8.2.5).
- Declare namespace-scope constants const instead of constexpr (Rule 4.1.2).

CI changes:
- Add coding-standards.yaml with the remaining MISRA deviations and their justifications.
- Index the deviations into the CodeQL database with the coding-standards scripts at v2.62.0, pinned by sha256.
- Disapply the advisory Rule 21.6.1, as the KVS uses std::string, std::map and std::vector by design.

This changes the public API.
Assigning to an rvalue Kvs or KvsValue no longer compiles.
KvsValue::GetValue on a temporary returns a value instead of a reference.
The size of KvsValue::Type changes, which affects the ABI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@arkjedrz
arkjedrz force-pushed the arkjedrz_codeql-cpp-fixes branch from 7261474 to c7905f2 Compare November 2, 2026 12:49

@karolnowak karolnowak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks good to me - good starting point.
It would be good to have a cmd to check code violations locally.

@arkjedrz

arkjedrz commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Regarding local repro #645

@PandaeDo
PandaeDo added this pull request to the merge queue Nov 2, 2026
Merged via the queue into eclipse-score:main with commit 11f1c8a Nov 2, 2026
17 checks passed
@PandaeDo
PandaeDo deleted the arkjedrz_codeql-cpp-fixes branch November 2, 2026 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants