Skip to content

refactor: Code simplification and consistency improvements #39

@rianjs

Description

@rianjs

Summary

Address code duplication, inconsistencies, and minor issues identified during code review of recent additions.

High Priority

1. Duplicate formatBool function

Files:

  • internal/cmd/schemas/schemas.go:232-237
  • internal/cmd/workflows/workflows.go:140-145

Identical implementations that should be extracted to a shared utility package (e.g., internal/cmd/shared/format.go or add to an existing helper).

Medium Priority

2. Missing --force flag on delete commands

Files:

  • internal/cmd/schemas/schemas.go (delete command)
  • internal/cmd/workflows/workflows.go (delete command)

Other delete commands (e.g., contacts) have a --force flag with safety warnings. Schema and workflow deletes execute immediately without confirmation. Add --force for consistency on destructive operations.

3. Inline interface types in graphql.go

File: internal/cmd/graphql/graphql.go:188-253

Helper functions define inline interface types which is unusual compared to other command files. Refactor to use the View type directly or named interface types.

Low Priority

4. Potential bug in GetRootTypes underscore check

File: api/graphql.go:293

Current code: t.Name[0:1] != "_" checks for single underscore
GraphQL internal types start with double underscore (__Schema, __Type)

Should use !strings.HasPrefix(t.Name, "__") instead.

5. String concatenation in ErrorMessages

File: api/graphql.go:44-60

Uses string concatenation in a loop. Could be simplified with strings.Join.

Files to Modify

  • internal/cmd/shared/format.go (new file for shared utilities)
  • internal/cmd/schemas/schemas.go
  • internal/cmd/workflows/workflows.go
  • internal/cmd/graphql/graphql.go
  • api/graphql.go

Acceptance Criteria

  • formatBool extracted to shared package and imported where needed
  • Delete commands have --force flag with confirmation prompt
  • Inline interfaces replaced with proper types
  • GetRootTypes uses strings.HasPrefix for __ check
  • ErrorMessages uses strings.Join
  • All tests pass
  • No new lint issues

Effort

Low-Medium - Straightforward refactoring

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions