Skip to content

refactor: replace global render registry with VerboseOutputFormatter interface#8

Merged
lburgazzoli merged 1 commit intoopendatahub-io:mainfrom
lburgazzoli:renderer
Feb 16, 2026
Merged

refactor: replace global render registry with VerboseOutputFormatter interface#8
lburgazzoli merged 1 commit intoopendatahub-io:mainfrom
lburgazzoli:renderer

Conversation

@lburgazzoli
Copy link
Copy Markdown
Member

@lburgazzoli lburgazzoli commented Feb 16, 2026

Replace the global mutable render registry (render_registry.go) with a
VerboseOutputFormatter interface that checks can optionally implement.
This eliminates global state and init-time side effects, making the
rendering extensible through Go's standard interface mechanism.

Key changes:

  • Remove render_registry.go and its global maps/mutex
  • Add VerboseOutputFormatter interface and DefaultVerboseFormatter
  • Simplify outputImpactedObjects to render per-check instead of
    aggregating by group/kind/checkType
  • Implement VerboseOutputFormatter on ImpactedWorkloadsCheck
  • Remove unused maxDisplay truncation logic from notebook renderer

Co-authored-by: Cursor cursoragent@cursor.com

Description

How Has This Been Tested?

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Summary by CodeRabbit

  • Refactor
    • Simplified lint check result output formatting by removing the customizable renderer system and introducing a streamlined verbose output formatter.
    • Impacted objects in lint results are now formatted consistently with improved namespace grouping and cluster-scoped item handling.
    • Updated notebook lint check output to use the new formatting approach.

…interface

Replace the global mutable render registry (render_registry.go) with a
VerboseOutputFormatter interface that checks can optionally implement.
This eliminates global state and init-time side effects, making the
rendering extensible through Go's standard interface mechanism.

Key changes:
- Remove render_registry.go and its global maps/mutex
- Add VerboseOutputFormatter interface and DefaultVerboseFormatter
- Simplify outputImpactedObjects to render per-check instead of
  aggregating by group/kind/checkType
- Implement VerboseOutputFormatter on ImpactedWorkloadsCheck
- Remove unused maxDisplay truncation logic from notebook renderer

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 16, 2026

📝 Walkthrough

Walkthrough

This PR removes the render registry pattern for customizable impacted object rendering and replaces it with an interface-based verbose formatter approach. Checks can now implement VerboseOutputFormatter to provide custom output formatting, while a new DefaultVerboseFormatter handles standard rendering.

Changes

Cohort / File(s) Summary
Registry Pattern Removal
pkg/lint/check/render_registry.go, pkg/lint/check/render_registry_test.go
Deleted entire render registry module including ImpactedObjectRenderer and ImpactedGroupRenderer types, registration/retrieval functions, concurrency-safe maps, and all supporting test cases. Removed 394 lines total.
Verbose Formatter Addition
pkg/lint/check/verbose_formatter.go, pkg/lint/check/verbose_formatter_test.go
Introduced VerboseOutputFormatter interface and DefaultVerboseFormatter struct to enable customizable verbose output. Includes namespace grouping, requester annotations, and comprehensive test coverage with mock implementations demonstrating interface integration patterns. Added 289 lines total.
Check Integration
pkg/lint/checks/workloads/notebook/impacted.go
Replaced free-function renderer with FormatVerboseOutput method on ImpactedWorkloadsCheck implementing VerboseOutputFormatter. Removed registry-based renderer registration and simplified group formatting for notebook objects by image.
Command Output Refactoring
pkg/lint/command_options.go
Refactored outputImpactedObjects to use per-check verbose formatter pattern instead of registry-based group renderers. Simplified rendering pipeline to check for VerboseOutputFormatter implementation on each check, falling back to DefaultVerboseFormatter, eliminating prior nested grouping logic.

Sequence Diagram

sequenceDiagram
    participant Cmd as Lint Command
    participant Check as Check Instance
    participant Formatter as Verbose Formatter
    participant DR as DiagnosticResult
    participant Out as Output Buffer

    Cmd->>Cmd: Iterate over checks with impacted objects
    Cmd->>Check: Type assert to VerboseOutputFormatter
    alt Check implements VerboseOutputFormatter
        Cmd->>Check: FormatVerboseOutput(out, dr)
        Check->>DR: Read ImpactedObjects
        Check->>Out: Write custom formatted output
    else Check does not implement interface
        Cmd->>Formatter: Create DefaultVerboseFormatter
        Cmd->>Formatter: FormatVerboseOutput(out, dr)
        Formatter->>DR: Read ImpactedObjects
        Formatter->>Formatter: Group by namespace
        Formatter->>Out: Write formatted output
    end
    Formatter->>Out: Return formatted impacted objects
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Poem

🐰 The registry fades, interfaces bloom,

Each check now formats its own room,

No more global maps or keys,

Just formatters dancing with ease,

Simplicity reigns—let verbosity zoom! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.27% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main architectural change: replacing a global render registry with an interface-based approach.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lburgazzoli
Copy link
Copy Markdown
Member Author

@andyatmiami changes a little bit the verbose output renderer as my original implementation was, well, clunky. It should preserve your output formatting for notebooks but having some additional review from your would be very appreciated

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
pkg/lint/checks/workloads/notebook/impacted.go (1)

3-6: Consider using the standard io import name for consistency.

The io package is aliased as iolib here (line 6), while the VerboseOutputFormatter interface in verbose_formatter.go uses the standard io import. This works correctly since both resolve to the same io.Writer type, but it's a minor inconsistency. If the alias exists to avoid a conflict with another io identifier in this file, a comment would help; otherwise, aligning with the standard name improves readability.

Copy link
Copy Markdown
Contributor

@andyatmiami andyatmiami left a comment

Choose a reason for hiding this comment

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

/lgtm

  • more idiomatic go pattern
  • no loss of functionality while reducing lines of code
  • notebooks impacted-object check still renders appropriately

Great improvement - no notes - thanks!

@lburgazzoli lburgazzoli merged commit de6a1ff into opendatahub-io:main Feb 16, 2026
5 checks passed
@lburgazzoli lburgazzoli deleted the renderer branch February 16, 2026 19:34
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