Repository navigation
Conversation
kyasbal
requested review from
K53,
RyuSA,
jyane,
kkuchima and
renamoo
as code owners
December 1, 2026 04:41
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors the pkg/common/flag package to reduce code duplication and improve performance. It introduces a generic registerFlag helper function to unify the registration of different flag types (String, Bool, Int, Float64) and optimizes DumpAll using strings.Builder. Additionally, it expands test coverage significantly by adding comprehensive unit tests for Parsed, Reset, DumpAll, PrintDefaults, and environment variable parsing errors. I have no further feedback to provide as the changes are clean and well-tested.
Go Quality Report (
|
| Metric | Result |
|---|---|
| Changed Scope | 1 prod file(s), 1 test file(s), 32 unit(s) |
| Patch Coverage | 100.0% (43/43 lines) |
| Mutation Score | 100.0% (17/17 killed, 0 survived) |
| Function Similarity | OK (4 new unit(s), 0 matches across 3194 corpus units) |
Commit: 9936524d2338 · Cloud Build Logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Aligns
pkg/common/flagwith KHI Go coding and testing conventions without changing exported APIs:String/Bool/Int/Float64registration logic into a shared genericregisterFlag[T]helper withformatUsageWithEnvKey,isProvidedFromCommandLineArgs, andlookupEnvValue(os.LookupEnv).strconv.ParseInt(envValue, 10, 64)+int(...)withstrconv.Atoito prevent silent 64-to-32-bit overflow truncation on 32-bit targets, and wraps integer/float environment variable parse errors with%wand contextual flag/env metadata.DumpAlltostrings.Builder, updatesResetto clear slices tonil, and clarifies package and function GoDoc comments (including non-concurrency of package-global state and existingBool/Reset/Parsecontracts).FOOisolation and a coincidental pass inTestBool, updatessetCommandlineArgumentsto useflag.ContinueOnErrorandt.Cleanup, and adds focused tests forParsed,Reset,DumpAll,PrintDefaults, and env-var parse errors (85.8%→100.0%statement coverage).Verification
make pre-push— PASS (0 mustfix, 0 advisory, 0 skipped)make qa-all-advisory CODEQUALITY_SIMILARITY=true— PASS (0 mustfix, 0 advisory, 0 skipped; 17/17 mutants killed, 0 similarity advisories)go test -race -count=1 -cover ./pkg/common/flag/... ./pkg/parameters/... ./pkg/core/init/default/...— PASS (pkg/common/flag:100.0%statement coverage)