Skip to content

[lint-monster] Fix: Unchecked type assertions and parameter issues (33 issues) #35109

@github-actions

Description

@github-actions

Lint Group 3: Type Assertion Safety and Function Parameter Issues

Finding Count: 33 issues

Subgroup A: Unchecked Type Assertions (31 issues)

Representative Examples:

  • pkg/parser/virtual_fs.go:76:9: type assertion x.(*FrontmatterResult) is unchecked
  • pkg/workflow/dispatch_repository.go:164:3: type assertion x.(map[string]any) is unchecked
  • pkg/cli/jsonworkflow_to_markdown.go:455:76: type assertion x.(string) is unchecked
  • pkg/linters/excessivefuncparams/excessivefuncparams.go:41:9: type assertion x.(*go/ast.FuncDecl) is unchecked
  • Multiple unchecked assertions in pkg/linters/* analyzer code

Fix: Replace all unchecked assertions with two-value form:

// ❌ BEFORE
value := x.(SomeType)

// ✅ AFTER
value, ok := x.(SomeType)
if !ok {
    return fmt.Errorf("expected type SomeType, got %T", x)
}

Subgroup B: Function Parameter Limits

Issue:

  • pkg/cli/update_manifest.go:174:6: updateManifestManagedWorkflow has 9 parameters (limit: 8)

Fix: Refactor function signature to use an options struct or config parameter:

// ❌ BEFORE: 9+ parameters
func updateManifestManagedWorkflow(a, b, c, d, e, f, g, h, i string) { ... }

// ✅ AFTER: Single config struct
type UpdateConfig struct {
    Param1 string
    Param2 string
    // ... other fields
}
func updateManifestManagedWorkflow(cfg UpdateConfig) { ... }

Subgroup C: Resource Management

Issue:

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

Fix: Add defer close immediately after successful file open:

// ❌ BEFORE
file, err := os.Open(filename)
if err != nil { ... }
// ... other code ...
file.Close()

// ✅ AFTER
file, err := os.Open(filename)
if err != nil { ... }
defer file.Close()
// ... other code ...

Remediation Checklist

  • Find assertions: Use grep 'type assertion.*is unchecked' lint-diagnostics.txt to identify all 31 assertion issues
  • Fix assertions: Replace with two-value form v, ok := x.(Type) pattern
  • Handle errors: Add appropriate error handling for type assertion failures
  • Refactor updateManifestManagedWorkflow: Convert 9-parameter function to options struct
  • Fix file close: Add defer file.Close() after os.Open() in workflows.go
  • Validate: Run make golint-custom to verify all 33 issues are resolved
  • Test: Run affected package tests to ensure no regressions

Reference: See .github/skills/error-recovery-patterns/SKILL.md for error handling patterns.

Files to Edit:

  • pkg/parser/virtual_fs.go
  • pkg/workflow/dispatch_repository.go, compiler_jobs.go, etc.
  • pkg/cli/jsonworkflow_to_markdown.go, workflows.go, update_manifest.go
  • pkg/linters//.go (14 analyzer files with assertion issues)

Generated by 🧌 LintMonster · haiku45 104.8K ·

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

Metadata

Metadata

Labels

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