Skip to content

Add golangci-lint#9

Merged
lucacome merged 3 commits into
masterfrom
chore/add-golangci
Apr 15, 2026
Merged

Add golangci-lint#9
lucacome merged 3 commits into
masterfrom
chore/add-golangci

Conversation

@lucacome
Copy link
Copy Markdown
Member

@lucacome lucacome commented Dec 4, 2024

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 the master branch. This includes steps for setting up the Go environment and running Go lint and actionlint.

  • GolangCI configuration: Updated the .golangci.yml file to configure various linters and their settings, such as misspell, revive, govet, and enabling multiple linters like errcheck, staticcheck, and unused. This configuration ensures comprehensive linting coverage.

Code style enhancements:

  • Logging function comments: Standardized the comments for logging functions in log/log.go by 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.go and utils/fields_test.go to maintain a clean and consistent code format. [1] [2] [3]

Summary by CodeRabbit

  • Chores

    • Added automated code linting workflow to enforce code quality standards.
    • Introduced linting configuration for consistent code style checks.
  • Bug Fixes

    • Improved field type conversion handling in logging utilities for better reliability.
    • Optimized memory allocation in logging operations.
  • Tests

    • Enhanced test execution efficiency with parallel test runs.

@github-actions github-actions Bot added the chore label Dec 4, 2024
Copilot AI review requested due to automatic review settings April 15, 2026 02:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.yml configuration 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.

Comment thread .github/workflows/lint.yml Outdated
@lucacome lucacome force-pushed the chore/add-golangci branch from fafbc6b to 3230e17 Compare April 15, 2026 02:09
@lucacome lucacome force-pushed the chore/add-golangci branch from 3230e17 to 250c987 Compare April 15, 2026 02:13
@lucacome
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

Warning

Rate limit exceeded

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

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 @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: 1f4cfeb0-d995-4dea-b135-9af689a33d24

📥 Commits

Reviewing files that changed from the base of the PR and between 250c987 and d91e18a.

📒 Files selected for processing (2)
  • .github/workflows/lint.yml
  • utils/fields_test.go

Walkthrough

This 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

Cohort / File(s) Summary
GitHub Actions and Linting Configuration
.github/workflows/lint.yml, .golangci.yml
Added CI workflow file for running Go and Actions linting with concurrency controls; added comprehensive GolangCI-Lint configuration specifying enabled linters, per-linter settings, and exclusion rules for generated and third-party code.
Logging Updates
log/log.go
Updated doc comments for logging helper functions with proper terminal periods; modified slice allocation in logSpan to use capacity-only initialization with append pattern.
Type Conversion Utilities
utils/fields.go, utils/fields_test.go
Enhanced ZapFieldToOpentracing type conversions with safety annotations (nolint directives), replaced unsafe type assertions with checked assertions including fallbacks, and added t.Parallel() to test function.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title "Add golangci-lint" directly matches the main objective of the PR, which is adding linting infrastructure via golangci-lint configuration and GitHub Actions workflow.
Docstring Coverage ✅ Passed Docstring coverage is 91.67% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/add-golangci

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 (2)
.github/workflows/lint.yml (1)

42-45: Keep actionlint’s ShellCheck integration enabled.

reviewdog/action-actionlint enables ShellCheck by default, and actionlint uses ShellCheck to analyze run: 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.go now handles invalid zapcore.StringerType and zapcore.ErrorType payloads without panicking, but this table still only exercises the well-typed cases. A couple of malformed zapcore.Field inputs 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

📥 Commits

Reviewing files that changed from the base of the PR and between b5c2e80 and 250c987.

📒 Files selected for processing (5)
  • .github/workflows/lint.yml
  • .golangci.yml
  • log/log.go
  • utils/fields.go
  • utils/fields_test.go

Comment thread .github/workflows/lint.yml
@lucacome lucacome enabled auto-merge (squash) April 15, 2026 02:31
@lucacome lucacome merged commit c832905 into master Apr 15, 2026
9 checks passed
@lucacome lucacome deleted the chore/add-golangci branch April 15, 2026 02:31
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.

2 participants