refactor: resolve goconst findings via constants and parser unification - #250
Open
kazz187 wants to merge 1 commit into
Open
refactor: resolve goconst findings via constants and parser unification#250kazz187 wants to merge 1 commit into
kazz187 wants to merge 1 commit into
Conversation
golangci-lint 2.13.1 upgraded goconst to 1.11.0, which widened repeated-literal counting from file scope to package scope (221 findings, up from 21). These are legitimate detections rather than a lapsed config, so resolve them as a real refactor instead of suppressing them. - .golangci.yml: ignore-tests (test fixture duplication is desirable) and skip "true"/"false", the stringly-typed metadata booleans. Thresholds unchanged. - internal/claudemd: new package unifying the four duplicated frontmatter parsers (skill/agent x file/string). The string-based agent parser now also handles block scalars, list-form tools:, and indented keys. - internal/eventbus/metadata.go: event metadata keys as shared constants. These values are a wire contract with the frontend, so they are unchanged. - cmd/taskguild-agent/constants.go: tool names, interaction option values, hook decisions, settings.json keys, metadata keys and content block fields. - pkg/clog, internal/template, internal/project: log attribute keys, entity types and seeded workflow status names. goconst 221 -> 0; total lint findings 2126 -> 1873 with no linter above baseline. Every literal-to-constant substitution was verified to resolve back to the identical string.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
golangci-lint 2.13.1 upgraded goconst 1.8.2 → 1.11.0, which widened repeated-literal counting from file scope to package scope. These are legitimate detections rather than a lapsed config, so they are resolved as a real refactor instead of being suppressed.
.golangci.yml—goconst.ignore-tests: true(test fixture duplication is desirable, and goconst counts across the package soexclusions.rulescannot substitute) plusignore-string-values: ['^(?:true|false)$']for the stringly-typed metadata booleans. Thresholds unchanged;ignore-map-keysdeliberately not used.internal/claudemd(new) — unifies the four duplicated frontmatter parsers (skill/agent × file/string) behindParseSkill/ParseAgent. Net −878 lines across the four call sites.internal/eventbus/metadata.go(new) — 19 event metadata keys as shared constants, replacing literals in 16 producer files and 4 reader sites.cmd/taskguild-agent/constants.go(new) — tool names, interaction option values, hook decisions,settings.jsonkeys, task-log metadata keys and content block fields.pkg/clog/internal/template/internal/project— log attribute keys, template entity types, seeded workflow status names and model.Also folded in two pre-existing duplications flagged during the work:
single_command_permission_cache.gonow reusessinglecommandpermission.TypeCommand/.TypeRedirect, and the twice-declaredstartMarker/endMarkerblock indirective.gois hoisted to package scope.Results
Notes for review
--uniq-by-line=false. golangci-lint rounds to one finding per line by default, which understated the real count (e.g.prompt.go:125carries both"type"and"text"but reports one). The true non-test count was 99 across 48 distinct literals, not 90.event-stream.ts,WorktreeList.tsx), so the values are frozen.slogattribute-name literals (different domain from event metadata, and excluded by goconst's defaultexclude-types: [Call]), task-log metadata maps (full_text/result_type/status_id/source), and display strings such as"**Tool:** `Bash`\n".internal/schedule/server_test.gois an unrelatedgolangci-lint fmtfix of the pre-existing gofumpt finding.Behaviour change to check
The string-based agent parser in
internal/agentmanager/agent_conflict.gopreviously usedstrings.CutPrefixand supported neither block scalars, list-formtools:/disallowedTools:, indented keys, norcontext. After unification it handles all of them. This is strictly more correct, and the new package has 31 unit tests covering it — but theResolveAgentConflictAGENT-choice path has not been exercised against real data.Test plan
go build ./...go test ./...— all packages pass; the 13 existing parser tests ininternal/skill/internal/agentpass unchanged, which is the regression guard for the unificationgo tool golangci-lint run --default=none --enable=goconst --max-issues-per-linter 0 --max-same-issues 0 --uniq-by-line=false ./...→ 0 issuesinternal/claudemdlints clean underdefault: all.claude/agents/*.mdwith block scalars