Skip to content

refactor: modularize traffic class monitoring and simplify loop closures - #185

Open
bhagathkrishnacdac wants to merge 1 commit into
omec-project:mainfrom
bhagathkrishnacdac:cognitive-complexity-commands-bess
Open

refactor: modularize traffic class monitoring and simplify loop closures#185
bhagathkrishnacdac wants to merge 1 commit into
omec-project:mainfrom
bhagathkrishnacdac:cognitive-complexity-commands-bess

Conversation

@bhagathkrishnacdac

Copy link
Copy Markdown

Description
This PR refactors _monitor_tcs to resolve cognitive complexity and flatten deeply nested closures. The helper functions, print generators, and rate calculations used to report traffic class (TC) runtime metrics have been moved to module-level private functions.

Key Changes

  • Decoupled Monitoring Loop: Extracted the core loop execution to _monitor_tc_loop to keep the primary CLI command interface clean.
  • Isolated Rate Calculations:
    • Moved the delta calculations and metric differential parsing to _calculate_tc_delta.
    • Moved TC scheduling ratio calculations (packets-per-batch and cycles-per-packet ratios) to _format_tc_data.
  • Standardized Terminal Layouts: Replaced nested print format generators with simplified, flat templates and modernized CSV output generation using list comprehensions instead of maps with lambdas.
  • Fixed Variable Scope Reliance: Correctly accessed the final TC index in the header generator instead of relying on scoped variable leakage from the loops.

Signed-off-by: bhagathkrishnacdac <bhagath.krishna@cdac.in>
@bhagathkrishnacdac
bhagathkrishnacdac requested a review from a team August 2, 2026 18:36
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.

1 participant