Skip to content

chore: prep batch 2 — refactor literals to constants for golangci-lint v2.12 - #23

Merged
fclairamb merged 3 commits into
mainfrom
chore/lint-prep-2-golangci-2-12
May 2, 2026
Merged

fclairamb merged 3 commits into
mainfrom
chore/lint-prep-2-golangci-2-12

Conversation

@fclairamb

Copy link
Copy Markdown
Owner

Summary

  • Continues the goconst prep for golangci-lint v2.12.0 (Renovate PR chore(deps): update dependency golangci/golangci-lint to v2.12.0 #20). v2.12 reports significantly more goconst issues than v2.11.4.
  • Adds shared constants in internal/notifications/constants.go, internal/mcp/constants.go, and canonical models.PeriodType* values.
  • Refactors literal strings (Block Kit type names, Slack API payload keys, JSON-RPC/JSON Schema keys, period types, DNS record types, error/message keys) into named constants across checkers, handlers, slack/discord/googlechat/mattermost senders, MCP tools, prommetrics, and CLI.

Test plan

🤖 Generated with Claude Code

…compatibility

Continues the goconst preparation for the golangci-lint v2.12.0 upgrade
(Renovate PR #20). v2.12 detects significantly more goconst occurrences
than v2.11.4 and refused this codebase outright until they were addressed.

Refactor highlights:
- internal/notifications/constants.go - shared productName,
  productMonitoring, fieldLabelMonitor across discord/googlechat/
  mattermost/opsgenie/ntfy/pushover senders
- internal/mcp/constants.go - shared JSON-RPC and JSON Schema
  property keys (jsonRPCVersion, schemaKey*, prop*) across all
  tool definitions
- internal/db/models/result.go - canonical PeriodType{Raw,Hour,
  Day,Month} constants used by aggregation jobs and worker code
- internal/checkers/checkdns/checker.go - record type constants
  (recordTypeA/AAAA/CNAME/MX/NS/TXT/SOA) used consistently across
  the lookup switch and samples
- internal/checkers/check{docker,mongodb,ssl,js,dns}/checker.go -
  use checkerdef.OutputKeyError instead of the literal "error"
- internal/handlers/auth/handler.go - fieldBody/fieldPassword/
  fieldCode constants
- internal/handlers/{checks,statuspages,maintenancewindows}/
  handler.go - fieldBody constants
- internal/handlers/incidents/service.go - keyCheckUID/keyCheckSlug
- internal/integrations/slack/types.go - ActionAddCheck constant;
  client.go - apiKey{Channel,Text,User,View}
- internal/checkworker/worker.go - periodTypeRaw, outputKeyMessage
- pkg/cli/constants.go - keySuccess/keyMessage/keyFailed
- internal/prommetrics/metrics.go - use existing labelStatus/
  labelRegion/labelOrganization/labelCheckSlug constants
- internal/jobs/jobtypes/job_aggregation.go - alias jobtypes
  period* constants to models.PeriodType*

Net: 0 lint issues; tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@fclairamb
fclairamb enabled auto-merge (squash) May 1, 2026 23:53
fclairamb and others added 2 commits May 2, 2026 01:53
Per code review on PR #23: every literal map key in
internal/handlers/incidents/service.go now has a named constant —
keyStartedAt, keyResultUID, keyResolvedAt, keyDurationSeconds,
keyTotalFailures, keyFailureCount, keyEscalationThreshold,
keyRelapseCount, keyEffectiveRecoveryThreshold.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The E2E job intermittently fails when GitHub-hosted runners cannot resolve
azure.archive.ubuntu.com during apt-get install of Playwright system fonts
(fonts-ipafont-gothic etc.). Wrap the install command in a 3-attempt retry
loop so transient DNS resolution failures auto-recover.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@fclairamb
fclairamb merged commit 4cbf3d9 into main May 2, 2026
10 checks passed
@fclairamb
fclairamb deleted the chore/lint-prep-2-golangci-2-12 branch May 2, 2026 00:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant