Skip to content

[lint-monster] Lint Group 3: Parameter count & resource management (2 violations) #34853

@github-actions

Description

@github-actions

Lint Issue Group 3: Parameter Count & Resource Management Fixes

Summary

2 lint violations in the pkg/cli/ package affecting function parameters and file resource management. Quick wins to clean up remaining issues.

Issue Details

Category: Code style / resource safety
Affected Files:

  1. pkg/cli/update_manifest.go:174
  2. pkg/cli/workflows.go:403

Violation 1: Excessive Function Parameters

File: pkg/cli/update_manifest.go:174
Function: updateManifestManagedWorkflow
Issue: Has 9 parameters (limit: 8)

Current Pattern:

func updateManifestManagedWorkflow(
  param1, param2, param3, param4,
  param5, param6, param7, param8,
  param9 Type) error

Expected Fix:
Use an options struct to encapsulate parameters > 8:

type updateManifestOpts struct {
  param1, param2, param3, param4,
  param5, param6, param7, param8,
  param9 Type
}

func updateManifestManagedWorkflow(opts updateManifestOpts) error

Violation 2: File Close Not Deferred

File: pkg/cli/workflows.go:403
Issue: file Close() should be deferred immediately after successful open

Current Pattern:

file, err := os.Open(path)
if err != nil {
  return err
}
// ... many lines of code ...
file.Close()  // Problem: not deferred

Expected Fix:

file, err := os.Open(path)
if err != nil {
  return err
}
defer file.Close()
// ... code ...
// Auto-closes on return or panic

Expected Outcome

Both violations resolved by:

  1. Refactoring updateManifestManagedWorkflow to use an options struct
  2. Adding defer file.Close() in workflows.go
  3. No behavioral changes; only style and safety improvements
  4. All fixes verified with make golint-custom

Remediation Checklist

  • Fix pkg/cli/update_manifest.go:174:
    • Create updateManifestOpts struct with all parameters
    • Update function signature to take opts parameter
    • Update function body to use opts.fieldName
    • Update callers of this function
  • Fix pkg/cli/workflows.go:403:
    • Find the file.Close() call
    • Move it to be immediately after the successful os.Open() call
    • Convert to defer file.Close()
  • Run make golint-custom and verify both violations are gone
  • Run make test-unit to ensure no regressions
  • Commit with message: "refactor: fix parameter count and defer file close in pkg/cli"

Skill Guidance

Use developer SKILL for:

  • Function design patterns
  • Resource management best practices
  • Code organization principles

Notes

  • These are the final 2 lint violations once the large groups are fixed
  • Both are low-complexity changes with straightforward solutions
  • Ensure all callers of updateManifestManagedWorkflow are updated to use the new signature

Generated by 🧌 LintMonster · haiku45 162.7K ·

  • expires on Jun 2, 2026, 3:52 AM UTC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions