-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: Code simplification and consistency improvements #39
Description
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-237internal/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.gointernal/cmd/workflows/workflows.gointernal/cmd/graphql/graphql.goapi/graphql.go
Acceptance Criteria
-
formatBoolextracted to shared package and imported where needed - Delete commands have
--forceflag with confirmation prompt - Inline interfaces replaced with proper types
- GetRootTypes uses
strings.HasPrefixfor__check - ErrorMessages uses
strings.Join - All tests pass
- No new lint issues
Effort
Low-Medium - Straightforward refactoring