Summary
_build_cli_args in rusty_comms_plugin.py uses a long chain of explicit if statements to map TestRunConfig fields to CLI flags. This works but becomes harder to maintain as new flags are added — each new field requires a new conditional block with its own formatting logic.
Suggestion
Replace the if-chain with a table-driven approach — e.g. a list of (field_name, flag, transform) tuples iterated in a loop:
FLAG_MAP = [
("message_size", "-s", str),
("msg_count", "-i", str),
("duration", "-d", None),
("concurrency", "-c", str),
("buffer_size", "--buffer-size", str),
...
]
for field, flag, transform in FLAG_MAP:
value = getattr(params, field, None)
if value is not None:
args.extend([flag, transform(value) if transform else value])
Boolean flags and special cases (like percentiles with repeated --percentiles args, or mechanisms which uses positional args) would need separate handling, but the bulk of the simple value flags could collapse into the loop.
Benefits
- Adding a new CLI flag becomes a one-line table entry instead of a new if-block
- Reduces risk of inconsistencies in flag formatting
- Easier to audit the full set of supported flags at a glance
Notes
Not urgent — the current implementation is correct and readable. This is a maintainability improvement for when the next batch of flags is added.
Summary
_build_cli_argsinrusty_comms_plugin.pyuses a long chain of explicitifstatements to mapTestRunConfigfields to CLI flags. This works but becomes harder to maintain as new flags are added — each new field requires a new conditional block with its own formatting logic.Suggestion
Replace the if-chain with a table-driven approach — e.g. a list of
(field_name, flag, transform)tuples iterated in a loop:Boolean flags and special cases (like
percentileswith repeated--percentilesargs, ormechanismswhich uses positional args) would need separate handling, but the bulk of the simple value flags could collapse into the loop.Benefits
Notes
Not urgent — the current implementation is correct and readable. This is a maintainability improvement for when the next batch of flags is added.