Skip to content

kvs: drop single point of return rule - #535

Merged
PandaeDo merged 1 commit into
eclipse-score:mainfrom
qorix-group:arkjedrz_drop-single-point-of-return
Oct 20, 2026
Merged

PandaeDo merged 1 commit into
eclipse-score:mainfrom
qorix-group:arkjedrz_drop-single-point-of-return

Conversation

@arkjedrz

Copy link
Copy Markdown
Contributor

Drop single point of return rule.
Functions complexity is decreased by allowing an early return.

Resolves #522

Drop single point of return rule.
Functions complexity is decreased by allowing an early return.
@arkjedrz arkjedrz self-assigned this Oct 19, 2026
@arkjedrz
arkjedrz deployed to workflow-approval October 19, 2026 14:36 — with GitHub Actions Active
@arkjedrz
arkjedrz deployed to workflow-approval October 19, 2026 14:36 — with GitHub Actions Active
@github-actions

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: b6cff1c9-91f5-4781-be0d-ba2a11841f00
Computing main repo mapping: 
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: 
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 (51 packages loaded, 14 targets configured)

Analyzing: target //:license-check (102 packages loaded, 38 targets configured)

Analyzing: target //:license-check (144 packages loaded, 3236 targets configured)

Analyzing: target //:license-check (153 packages loaded, 7817 targets configured)

Analyzing: target //:license-check (161 packages loaded, 9663 targets configured)

Analyzing: target //:license-check (161 packages loaded, 9664 targets configured)

Analyzing: target //:license-check (161 packages loaded, 9664 targets configured)

Analyzing: target //:license-check (166 packages loaded, 11675 targets configured)

INFO: Analyzed target //:license-check (168 packages loaded, 15897 targets configured).
[7 / 15] Creating runfiles tree bazel-out/k8-fastbuild/bin/license.check.license_check.runfiles; 0s local ... (2 actions, 1 running)
[12 / 16] JavaToolchainCompileClasses external/rules_java+/toolchains/platformclasspath_classes; 0s disk-cache, processwrapper-sandbox ... (2 actions running)
INFO: From Generating Dash formatted dependency file ...:
INFO: Successfully converted 50 packages from Cargo.lock to bazel-out/k8-fastbuild/bin/formatted.txt
[14 / 16] JavaToolchainCompileBootClasspath external/rules_java+/toolchains/platformclasspath.jar; 0s disk-cache, processwrapper-sandbox
INFO: Found 1 target...
Target //:license.check.license_check up-to-date:
  bazel-bin/license.check.license_check
  bazel-bin/license.check.license_check.jar
INFO: Elapsed time: 27.422s, Critical Path: 2.89s
INFO: 16 processes: 12 internal, 3 processwrapper-sandbox, 1 worker.
INFO: Build completed successfully, 16 total actions
INFO: Running command line: bazel-bin/license.check.license_check ./formatted.txt <args omitted>
[main] INFO Querying Eclipse Foundation for license data for 42 items.
[main] ERROR Error response from the Eclipse Foundation 504

@github-actions

Copy link
Copy Markdown
Contributor

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

@vinodreddy-g vinodreddy-g 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.

LGTM

@PandaeDo
PandaeDo added this pull request to the merge queue Oct 20, 2026
Merged via the queue into eclipse-score:main with commit c678ccd Oct 20, 2026
19 checks passed
@PandaeDo
PandaeDo deleted the arkjedrz_drop-single-point-of-return branch October 20, 2026 11:35
Comment thread score/kvs/kvs.cpp
kvs.logger_->LogInfo() << "[instance=" << instance_id.id << "]"
<< "[snapshot=" << snapshot_id.id << "]"
<< "[maxSnapshotCount=" << kvs.max_snapshots_ << "] KVS opened";
return kvs;

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.

this function should return score::Result now it is returning kvs but the issue here kvs copy operations is deleted because it contains unique pointers .

please reuturn std::move(kvs);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is implicit: https://stackoverflow.com/a/9532647
GCC even has flags to detect unnecessary std::move: https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/C_002b_002b-Dialect-Options.html search for pessimizing-move and redundant-move.

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.

in this case kvs is not copy elision or not NRVO(Named Return Value optimization) because function return Result not kvs . but it working in this case because return initalization: compiler first tries to apply move and same time Result's constructor accept T&& and using std::forward() so make R-Value conversion

tested when i trued to enforce return fuction to return Lvalue then i got error :
image

in summary , you do not need to fix it for now .

Comment thread score/kvs/kvs.cpp
}

return result;
return result_value;

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.

here unordered_map copyable but to avoid silently deep-copy i would recommed to return using std::move(result_value)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is implicit: https://stackoverflow.com/a/9532647
GCC even has flags to detect unnecessary std::move: https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/C_002b_002b-Dialect-Options.html search for pessimizing-move and redundant-move.

Comment thread score/kvs/kvs.cpp
}

return result;
return keys;

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.

here vector is also copyable but to avoid silently deep-copy i would recommed to return using std::move(result_value)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is implicit: https://stackoverflow.com/a/9532647
GCC even has flags to detect unnecessary std::move: https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/C_002b_002b-Dialect-Options.html search for pessimizing-move and redundant-move.

Comment thread score/kvs/kvs.cpp
}
logger_->LogError() << "Error: Could not get size of file" << file_path << ":" << ec.message();
return score::MakeUnexpected(ErrorCode::PhysicalStorageFailure);
else

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.

[minor] un necessary else , we can remove it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I found keeping else if and else in some places to be somewhat more readable, personal preference, fix unnecessary.

}
return KvsValue(static_cast<int32_t>(n.value()));
}
else if (typeStrV == "u32")

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.

[minor] here since you already return from if so else if is not needed anymore .

recommendation to have code like follwoing :

if(typeStrV == "i32") {.....; return KvsValue(..);}
if(typeStrV == "u32") {.....; return KvsValue(..);}
if(typeStrV == "i64") {.....; return KvsValue(..);}
.............
return score::MakeUnexpected(ErrorCode::

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I found keeping else if and else in some places to be somewhat more readable, personal preference, fix unnecessary.

This branch was successfully deployed

1 active deployment
workflow-approval — aa20898e Deployed Oct 19, 2026 by arkjedrz via qnx-build (per-arm64-qnx) / approval #1020
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.

Drop single point of return rule

4 participants