Add golangci-lint#9
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds repository-wide linting via GolangCI-Lint and actionlint, and applies a few small formatting/comment-style cleanups to align the Go code with stricter lint rules.
Changes:
- Add a new GitHub Actions workflow to run Go linting and actionlint on pushes/PRs to
master. - Introduce a
.golangci.ymlconfiguration enabling a broad set of linters and rules. - Minor comment punctuation and whitespace formatting updates in Go sources/tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
.github/workflows/lint.yml |
Adds CI jobs for golangci-lint and actionlint. |
.golangci.yml |
Configures enabled linters and linter settings for the repo. |
log/log.go |
Standardizes doc comments (punctuation) for exported logging helpers. |
utils/fields.go |
Removes an unnecessary blank line in the switch statement. |
utils/fields_test.go |
Removes unnecessary blank lines in the test. |
Comments suppressed due to low confidence (1)
log/log.go:93
- The comments for the DPanic helpers refer to the level as "dPanic". Zap’s level name is typically "DPanic" (capital D), so this reads like a typo/inconsistent terminology in user-facing documentation. Consider updating the wording to "DPanic" for consistency with the function/level name.
// DPanicWithContext logs on dPanic level and trace based on the context span if it exists.
func DPanicWithContext(ctx context.Context, log string, fields ...zapcore.Field) {
DPanicWithSpan(opentracing.SpanFromContext(ctx), log, fields...)
}
// DPanicWithSpan logs on dPanic level and add the logs on the trace if span exists.
func DPanicWithSpan(span opentracing.Span, log string, fields ...zapcore.Field) {
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
fafbc6b to
3230e17
Compare
3230e17 to
250c987
Compare
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 46 minutes and 6 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis PR introduces GitHub Actions linting workflows and configuration, updates logging helper documentation with proper punctuation, improves type conversion handling in utility functions with safety annotations, and enables parallel test execution. Changes
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
.github/workflows/lint.yml (1)
42-45: Keep actionlint’s ShellCheck integration enabled.
reviewdog/action-actionlintenables ShellCheck by default, andactionlintuses ShellCheck to analyzerun:scripts. Setting-shellcheck ""disables that integration, so shell issues in workflow steps will stop being reported. (github.com)Suggested change
- name: Lint Actions uses: reviewdog/action-actionlint@v1 - with: - actionlint_flags: -shellcheck ""🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.github/workflows/lint.yml around lines 42 - 45, The workflow currently disables actionlint’s ShellCheck integration by setting actionlint_flags: -shellcheck ""; revert this so ShellCheck runs: remove the actionlint_flags entry (or set it to a value that does not disable shellcheck) in the step that uses reviewdog/action-actionlint@v1 (the step named "Lint Actions") so actionlint continues to analyze run: scripts with ShellCheck enabled.utils/fields_test.go (1)
20-99: Add regression cases for the new fallback branches.
utils/fields.gonow handles invalidzapcore.StringerTypeandzapcore.ErrorTypepayloads without panicking, but this table still only exercises the well-typed cases. A couple of malformedzapcore.Fieldinputs would lock in that new behavior.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@utils/fields_test.go` around lines 20 - 99, Add regression table entries to TestFieldsConversion that feed malformed zapcore.Field cases into ZapFieldToOpentracing: specifically include a zapcore.StringerType field whose Interface payload is not a fmt.Stringer (e.g., an int or nil) and a zapcore.ErrorType field whose Interface payload is not an error (e.g., a string or nil). For each case assert the returned opentracing field uses the graceful fallback (e.g., empty string or stringified value) by comparing Key(), String(), and Value() against the expected fallback opentracinglog.Field so the test locks in the non-panic behavior implemented in utils/fields.go and ZapFieldToOpentracing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/lint.yml:
- Around line 24-43: The workflow uses tag-pinned actions (actions/checkout@v6,
actions/setup-go@v6, golangci/golangci-lint-action@v9,
reviewdog/action-actionlint@v1) which are mutable; replace each uses: reference
with the corresponding full-length commit SHA for that action (e.g.,
actions/checkout@<full-commit-sha>) so the executed action is immutable—update
all occurrences in the workflow to their exact commit SHAs and verify those SHAs
point to the intended released versions before committing.
---
Nitpick comments:
In @.github/workflows/lint.yml:
- Around line 42-45: The workflow currently disables actionlint’s ShellCheck
integration by setting actionlint_flags: -shellcheck ""; revert this so
ShellCheck runs: remove the actionlint_flags entry (or set it to a value that
does not disable shellcheck) in the step that uses
reviewdog/action-actionlint@v1 (the step named "Lint Actions") so actionlint
continues to analyze run: scripts with ShellCheck enabled.
In `@utils/fields_test.go`:
- Around line 20-99: Add regression table entries to TestFieldsConversion that
feed malformed zapcore.Field cases into ZapFieldToOpentracing: specifically
include a zapcore.StringerType field whose Interface payload is not a
fmt.Stringer (e.g., an int or nil) and a zapcore.ErrorType field whose Interface
payload is not an error (e.g., a string or nil). For each case assert the
returned opentracing field uses the graceful fallback (e.g., empty string or
stringified value) by comparing Key(), String(), and Value() against the
expected fallback opentracinglog.Field so the test locks in the non-panic
behavior implemented in utils/fields.go and ZapFieldToOpentracing.
🪄 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: f993f6a4-4a1c-4216-a0dd-0950f4dfb982
📒 Files selected for processing (5)
.github/workflows/lint.yml.golangci.ymllog/log.goutils/fields.goutils/fields_test.go
This pull request introduces several changes to improve the linting process, enhance code quality, and ensure consistency in the logging functions. The most important changes include the addition of a GitHub Actions workflow for linting, configuration of linters for Go, and minor code style enhancements in the logging functions.
Linting and CI improvements:
GitHub Actions workflow for linting: Added a new GitHub Actions workflow (
.github/workflows/lint.yml) to run linting on push and pull request events to themasterbranch. This includes steps for setting up the Go environment and running Go lint and actionlint.GolangCI configuration: Updated the
.golangci.ymlfile to configure various linters and their settings, such asmisspell,revive,govet, and enabling multiple linters likeerrcheck,staticcheck, andunused. This configuration ensures comprehensive linting coverage.Code style enhancements:
Logging function comments: Standardized the comments for logging functions in
log/log.goby adding periods at the end of each comment. This change improves the readability and consistency of the code documentation. [1] [2] [3] [4] [5] [6] [7] [8]Code formatting: Removed unnecessary blank lines in
utils/fields.goandutils/fields_test.goto maintain a clean and consistent code format. [1] [2] [3]Summary by CodeRabbit
Chores
Bug Fixes
Tests