chore: simplify, modernize (Go 1.26), update deps#144
Conversation
- config.go: os.IsNotExist → errors.Is(fs.ErrNotExist) - etag.go: replace custom appendUint with strconv.AppendUint; drop dead helper - plugin.go: hoist cfgKey const (remove double Sprintf); value-range over Forbid/Allow slices; strings.NewReplacer for path sanitization; drop dead ext sanitize after ext is already clean
📝 WalkthroughWalkthroughThis PR refactors the Roadrunner static file plugin to use standard library functions and error handling conventions. Config validation adopts the standard errors package; ETag generation replaces custom helpers with ChangesCode Modernization and Standardization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
There was a problem hiding this comment.
Pull request overview
Refactors the static plugin for simplification and modernization: hoists a config-key constant, switches to value-range loops, consolidates path sanitization into a package-level strings.Replacer, replaces os.IsNotExist with errors.Is(err, fs.ErrNotExist), and replaces a custom appendUint helper with strconv.AppendUint.
Changes:
plugin.go: introducecfgKeyconstant andpathSanitizerglobal; cleaner range loops; remove redundant ext sanitization.etag.go: usestrconv.AppendUint, drop custom helper.config.go: use stdliberrors.Is/fs.ErrNotExist, alias roadrunner errors asrrerrors.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| plugin.go | Hoists cfgKey constant, adds shared pathSanitizer, simplifies loops. |
| etag.go | Replaces local appendUint with strconv.AppendUint. |
| config.go | Switches to stdlib errors.Is(fs.ErrNotExist); aliases errors import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Inline strings.ReplaceAll at the single call site instead of a package-level strings.Replacer var (+nolint:gochecknoglobals).
Exercise the missing-directory and path-is-a-file branches of Config.Valid, closing the codecov patch gap left by the os.IsNotExist -> errors.Is(fs.ErrNotExist) refactor.
There was a problem hiding this comment.
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 `@config.go`:
- Line 44: The user-facing error string in the rrerrors.Errorf call is
grammatically incorrect ("does not exists"); update the message in the call
rrerrors.E(op, rrerrors.Errorf("root directory '%s' does not exists", c.Dir)) to
use "does not exist" instead, keeping the same formatting and interpolation of
c.Dir and preserving the surrounding rrerrors.E and rrerrors.Errorf usage.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2b1e4dc6-c242-46ee-9e12-8d55cdbf46fb
📒 Files selected for processing (4)
config.goconfig_test.goetag.goplugin.go
Applied fixes
Simplify (S) — 3 applied:
plugin.go: hoistcfgKeyconstant, eliminating two identicalfmt.Sprintf("%s.%s", RootPluginName, PluginName)callsplugin.go: value-range overForbid/Allowslices (two loops)plugin.go:strings.NewReplacerfor path log-injection sanitization; remove dead duplicate sanitize onext(already stripped viapath.Ext)Modernize (M) — 2 applied:
config.go:os.IsNotExist→errors.Is(err, fs.ErrNotExist)(Go stdlib best practice)etag.go: customappendUinthelper →strconv.AppendUint; dead helper removedDeps
go get -u all && go mod tidyrun in root andtests/;go work syncrun at root. No version changes — all deps were already current.Summary by CodeRabbit
Bug Fixes
Tests
Refactor