Skip to content

[lint] fix goconst issues#230

Open
capcom6 wants to merge 1 commit intomasterfrom
lint/fix-goconst-issues
Open

[lint] fix goconst issues#230
capcom6 wants to merge 1 commit intomasterfrom
lint/fix-goconst-issues

Conversation

@capcom6
Copy link
Copy Markdown
Member

@capcom6 capcom6 commented May 7, 2026

Summary by CodeRabbit

  • Chores

    • Updated linter configurations across configuration modules to suppress additional lint rules.
  • Refactor

    • Centralized Prometheus metrics namespace and subsystem configuration across internal modules (JWT, events, push, SSE, online services, and worker executor) for improved maintainability.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack

Warning

Rate limit exceeded

@capcom6 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 45 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 172df3ce-1803-4ea2-8ea8-a6b1d9acc7ee

📥 Commits

Reviewing files that changed from the base of the PR and between 2b42ec6 and c4379d8.

📒 Files selected for processing (6)
  • internal/sms-gateway/jwt/metrics.go
  • internal/sms-gateway/modules/events/metrics.go
  • internal/sms-gateway/modules/push/metrics.go
  • internal/sms-gateway/modules/sse/metrics.go
  • internal/sms-gateway/online/metrics.go
  • internal/worker/executor/metrics.go
📝 Walkthrough

Walkthrough

This PR refactors Prometheus metric configuration across the SMS gateway and worker modules by extracting namespace and subsystem values into module-level constants, replacing hardcoded string literals in metric registration calls. Configuration lint directives are also expanded to suppress additional linters.

Changes

Metrics Namespace Centralization

Layer / File(s) Summary
Lint Configuration Updates
internal/config/config.go, internal/worker/config/config.go
//nolint directives expanded to suppress exhaustruct, mnd, and goconst linters.
JWT Metrics Centralization
internal/sms-gateway/jwt/metrics.go
metricsNamespace and metricsSubsystem constants introduced; metric registration now uses these constants instead of hardcoded "sms"/"auth".
Events Metrics Centralization
internal/sms-gateway/modules/events/metrics.go
metricsNamespace and metricsSubsystem constants introduced; counter metrics now reference these constants instead of hardcoded "sms"/"events".
Push Metrics Centralization
internal/sms-gateway/modules/push/metrics.go
metricsNamespace and metricsSubsystem constants introduced; all counter registrations now use these constants instead of duplicated "sms"/"push" strings.
SSE Metrics Centralization
internal/sms-gateway/modules/sse/metrics.go
metricsNamespace and metricsSubsystem constants introduced; gauge, counter, and histogram metrics now use these constants for namespace/subsystem configuration.
Online Metrics Centralization
internal/sms-gateway/online/metrics.go
metricsNamespace and metricsSubsystem constants introduced; all metric definitions (counter vectors, histograms, counter, gauge) now reference these constants.
Worker Executor Metrics Centralization
internal/worker/executor/metrics.go
metricsNamespace and metricsSubsystem constants introduced; gauge, counter-vector, and histogram-vector metrics now use these constants instead of hardcoded "worker"/"executor".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • android-sms-gateway/server#157: Both PRs modify internal/sms-gateway/modules/push/metrics.go (this PR centralizes namespace/subsystem configuration while the related PR introduces the metrics struct and constructors).
  • android-sms-gateway/server#206: Both PRs modify internal/config/config.go's Default() function (this PR adjusts the //nolint directive while the related PR changes JWT TTL configuration).
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: introducing constants to replace hardcoded strings for Prometheus metrics namespace/subsystem configuration, which directly addresses goconst linting violations.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
internal/worker/config/config.go (1)

35-35: ⚡ Quick win

Prefer narrowing goconst suppression scope.

Function-level //nolint:goconst can hide future constant-duplication findings in Default(). Prefer either extracting repeated literals (e.g., day/hour multipliers) into constants or applying a more targeted suppression only where needed.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/worker/config/config.go` at line 35, The file-level/function-level
suppression for goconst on Default() is too broad; narrow it by extracting
repeated literal multipliers (e.g., day/hour multipliers or any repeated
numeric/string literals used inside Default()) into named constants (e.g.,
DaySeconds, HourSeconds, DefaultTimeout) and then remove the general
"//nolint:goconst" on the function, or if a single expression still needs
suppression, move a targeted "//nolint:goconst" to that specific declaration.
Update the Default() function to use those new constants so goconst warnings are
resolved without suppressing the entire function.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/sms-gateway/jwt/metrics.go`:
- Around line 10-12: The metricsSubsystem value "jwt" duplicates the "jwt_"
prefix already present in the Name constants (e.g., "jwt_tokens_issued_total"),
producing names like sms_jwt_jwt_... and silently renaming metrics; fix by
either reverting metricsSubsystem back to "auth" (restore previous name
behavior) or by removing the "jwt_" prefix from all Name constants in this file
(aligning with other modules) and document the migration; locate and update the
metricsSubsystem variable and the Name constants referenced in this file (e.g.,
metricsSubsystem, metricsNamespace and the jwt_* Name constants) accordingly and
add a brief migration note if you choose to rename metrics.

---

Nitpick comments:
In `@internal/worker/config/config.go`:
- Line 35: The file-level/function-level suppression for goconst on Default() is
too broad; narrow it by extracting repeated literal multipliers (e.g., day/hour
multipliers or any repeated numeric/string literals used inside Default()) into
named constants (e.g., DaySeconds, HourSeconds, DefaultTimeout) and then remove
the general "//nolint:goconst" on the function, or if a single expression still
needs suppression, move a targeted "//nolint:goconst" to that specific
declaration. Update the Default() function to use those new constants so goconst
warnings are resolved without suppressing the entire function.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b554a80f-faa4-43ad-baf0-5d486d09ee98

📥 Commits

Reviewing files that changed from the base of the PR and between b83f22f and 2b42ec6.

📒 Files selected for processing (8)
  • internal/config/config.go
  • internal/sms-gateway/jwt/metrics.go
  • internal/sms-gateway/modules/events/metrics.go
  • internal/sms-gateway/modules/push/metrics.go
  • internal/sms-gateway/modules/sse/metrics.go
  • internal/sms-gateway/online/metrics.go
  • internal/worker/config/config.go
  • internal/worker/executor/metrics.go

Comment thread internal/sms-gateway/jwt/metrics.go
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

🤖 Pull request artifacts

Platform File
🐳 Docker GitHub Container Registry
🍎 Darwin arm64 server_Darwin_arm64.tar.gz
🍎 Darwin x86_64 server_Darwin_x86_64.tar.gz
🐧 Linux arm64 server_Linux_arm64.tar.gz
🐧 Linux i386 server_Linux_i386.tar.gz
🐧 Linux x86_64 server_Linux_x86_64.tar.gz
🪟 Windows arm64 server_Windows_arm64.zip
🪟 Windows i386 server_Windows_i386.zip
🪟 Windows x86_64 server_Windows_x86_64.zip

@capcom6 capcom6 force-pushed the lint/fix-goconst-issues branch from 2b42ec6 to d79783e Compare May 7, 2026 04:20
@capcom6 capcom6 force-pushed the lint/fix-goconst-issues branch from 60e4bfc to c4379d8 Compare May 8, 2026 05:12
@capcom6 capcom6 added the ready label May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant