Skip to content

♻️ refactor: remove redundant modernize workflow#203

Merged
ReneWerner87 merged 2 commits into
gofiber:masterfrom
alexandear-org:chore/enable-modernize-linter
May 25, 2026
Merged

♻️ refactor: remove redundant modernize workflow#203
ReneWerner87 merged 2 commits into
gofiber:masterfrom
alexandear-org:chore/enable-modernize-linter

Conversation

@alexandear

@alexandear alexandear commented May 24, 2026

Copy link
Copy Markdown
Contributor

This PR enables the modernize linter in the golangci-lint configuration. It also removes the now-redundant "Modernize Lint" workflow and fixes modernize lint issues.
These changes require upgrading golangci-lint to v2.12.2 and Go to 1.25.

Summary by CodeRabbit

Release Notes

  • Tests

    • Updated test loops to use modern iteration patterns and removed legacy closure-capture workarounds for improved compatibility.
  • Refactor

    • Modernized type checking and atomic value storage in internal utilities.
    • Updated directory entry sorting to use standard library helpers.
  • Chores

    • Removed unnecessary linter suppression directives.

Review Change Stack

Copilot AI review requested due to automatic review settings May 24, 2026 20:48
@alexandear alexandear requested a review from a team as a code owner May 24, 2026 20:48
@alexandear alexandear requested review from ReneWerner87, efectn, gaby and sixcolors and removed request for a team May 24, 2026 20:48
@ReneWerner87 ReneWerner87 added the ☢️ Bug Something isn't working label May 24, 2026
@alexandear alexandear force-pushed the chore/enable-modernize-linter branch from b172c5e to 8c35e61 Compare May 24, 2026 20:48
@alexandear alexandear changed the title fix: modernize lint issues; remove redundant workflow refactor: modernize lint issues; remove redundant workflow May 24, 2026
@coderabbitai

coderabbitai Bot commented May 24, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

This PR modernizes Go code patterns by removing deprecated loop-variable capture workarounds, upgrading to newer standard library APIs (atomic types, collection utilities, reflection constants), and cleaning up linter suppressions across the codebase.

Changes

Go Modernization and Loop Pattern Updates

Layer / File(s) Summary
Test loop variable capture cleanup and iteration pattern simplification
byteseq_test.go, common_test.go, convert_test.go, strings/case_test.go
Removes unnecessary tc := tc and c := c assignments from parallel test loops in Test_TrimSpace, Benchmark_TrimSpace, Benchmark_TrimSpaceBytes, Test_IncrementIPRange, and Test_ToString. Simplifies concurrency test goroutine spawning and ASCII iteration loops from index-based to range-based form.
Standard library API modernization
time.go, file.go, convert.go
Refactors timestamp caching to use atomic.Uint32 type methods (Load/Store) instead of package-level functions; adopts slices.Sort for directory name sorting; updates pointer-type detection from reflect.Ptr to reflect.Pointer.
Linter directive updates
common.go, format.go
Removes outdated //nolint:gosec suppressions from buffer-write operations in FormatUint32, FormatUint16, FormatInt16, and AppendInt functions. Adds //nolint:modernize directive with false-positive note to backward-iteration loop in IncrementIPRange.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • gofiber/utils#139: Both PRs modify the ASCII case conversion test logic in strings/case_test.go, including changes to the per-ASCII-byte iteration approach.
  • gofiber/utils#167: Both PRs touch convert.go's pointer handling—this PR updates the reflection constant check while #167 refines overall pointer-type handling logic.
  • gofiber/utils#136: Both PRs modify convert_test.go within Test_ToString, affecting subtest loop structure and variable capture patterns.

Suggested reviewers

  • gaby
  • sixcolors
  • ReneWerner87
  • efectn

Poem

🐰 The loops now flow with modern Go,
No shadowed vars to steal the show,
Fresh APIs dance where old ones were,
And linters rest with less to stir!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title mentions modernize workflow refactoring but does not reflect the primary changes: enabling the modernize linter in golangci-lint configuration and fixing modernize lint issues across multiple files. Update the title to reflect the main objective, such as 'Enable modernize linter and fix modernize lint issues' or 'Enable modernize linter in golangci-lint configuration'.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request modernizes the codebase by adopting Go 1.22 features, such as the new 'for range' integer syntax and the removal of redundant loop variable captures. It also updates the code to use modern APIs, including 'atomic.Uint32', 'reflect.Pointer', and the 'slices' package for sorting, while adding the 'modernize' linter to the configuration. Feedback was provided regarding the global disabling of the 'package-naming' linter, which may reduce maintainability and appears to be outside the scope of the modernization effort.

Comment thread .golangci.yml

Copilot AI left a comment

Copy link
Copy Markdown

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 integrates the modernize linter into the repository’s golangci-lint configuration and removes the dedicated Modernize workflow by fixing the newly surfaced modernize-related issues across the codebase.

Changes:

  • Enable the modernize linter in .golangci.yml and pin golangci-lint to v2.12.2 in the lint workflow.
  • Remove the standalone .github/workflows/modernize.yml workflow as redundant.
  • Apply modernize-driven refactors across utils (atomic typed values, slices.Sort, updated loop patterns, and test loop variable capture cleanups).

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
time.go Switch cached timestamp to atomic.Uint32 and use typed atomic methods.
strings/case_test.go Simplify ASCII iteration using modern range-over-integer syntax.
format.go Remove now-redundant gosec suppressions on bounded indexing/conversions.
file.go Replace sort.Strings with slices.Sort and update imports.
convert.go Modernize reflection pointer-kind check.
convert_test.go Remove no-longer-needed range-variable capture with parallel subtests.
common.go Add modernize suppression for a reverse-loop false positive in IP increment logic.
common_test.go Use range-over-integer loops and remove redundant range-variable captures.
byteseq_test.go Remove redundant range-variable captures in parallel tests/benchmarks.
.golangci.yml Enable modernize and disable revive’s package-naming rule.
.github/workflows/modernize.yml Remove redundant Modernize workflow.
.github/workflows/lint.yml Pin golangci-lint to v2.12.2 in the reusable lint workflow call.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gaby gaby changed the title refactor: modernize lint issues; remove redundant workflow ♻️ refactor: remove redundant modernize workflow May 24, 2026

@gaby gaby left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@codecov

codecov Bot commented May 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.85714% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.08%. Comparing base (867477f) to head (ad3d4a7).

Files with missing lines Patch % Lines
convert.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master     #203   +/-   ##
=======================================
  Coverage   84.08%   84.08%           
=======================================
  Files          14       14           
  Lines        1150     1150           
=======================================
  Hits          967      967           
  Misses        152      152           
  Partials       31       31           
Flag Coverage Δ
unittests 84.08% <92.85%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@convert.go`:
- Around line 216-218: The code calls reflect.ValueOf(arg).Kind() without
checking that the reflect.Value is valid, which causes ToString(nil) to panic;
update the ToString function to guard before calling Kind by checking
reflect.ValueOf(arg).IsValid() (or test arg == nil) and handling nil/invalid
values (return empty string or the intended zero value) before proceeding to
inspect pointers with Kind() and rv.IsNil(); ensure the existing branch that
handles reflect.Pointer && !rv.IsNil() still runs only after the validity check.
🪄 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: 33f69a7c-058a-4990-98ef-8f936d62e794

📥 Commits

Reviewing files that changed from the base of the PR and between 867477f and 8c35e61.

⛔ Files ignored due to path filters (3)
  • .github/workflows/lint.yml is excluded by !**/*.yml
  • .github/workflows/modernize.yml is excluded by !**/*.yml
  • .golangci.yml is excluded by !**/*.yml
📒 Files selected for processing (9)
  • byteseq_test.go
  • common.go
  • common_test.go
  • convert.go
  • convert_test.go
  • file.go
  • format.go
  • strings/case_test.go
  • time.go
💤 Files with no reviewable changes (2)
  • convert_test.go
  • byteseq_test.go
📜 Review details
🔇 Additional comments (7)
common.go (1)

121-121: LGTM!

format.go (1)

105-105: LGTM!

Also applies to: 109-109, 148-148, 152-152, 172-172, 176-176, 178-178, 213-213

time.go (1)

10-10: LGTM!

Also applies to: 19-19, 26-26, 38-38

file.go (1)

10-10: LGTM!

Also applies to: 49-49

common_test.go (2)

63-71: LGTM!


106-114: LGTM!

strings/case_test.go (1)

65-73: LGTM!

Comment thread convert.go
@gaby

gaby commented May 24, 2026

Copy link
Copy Markdown
Member

@alexandear

  • change the min go to 1.25.x
  • remove go 1.24.x
  • add 1.26.x to test workflow

@alexandear

Copy link
Copy Markdown
Contributor Author

@gaby thank you, updated.

@ReneWerner87 ReneWerner87 merged commit ea2559f into gofiber:master May 25, 2026
15 of 16 checks passed
@alexandear alexandear deleted the chore/enable-modernize-linter branch May 25, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working 🧹 Updates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants