Refactor loadFromFile to use bufio.Scanner#1791
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough
ChangesResolver File Loading and Domain Preprocessing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 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 unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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.
🧹 Nitpick comments (1)
pkg/runner/util.go (1)
11-28: 💤 Low valueHandle the
f.Close()error (or explicitly discard it) to satisfy errcheck.golangci-lint (
errcheck) flags the deferredf.Close()on line 16. For a read-only file the actual risk is negligible, but this will likely fail the CI lint gate. The simplest fix is an explicit discard.♻️ Proposed tweak
- defer f.Close() + defer func() { _ = f.Close() }()🤖 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 `@pkg/runner/util.go` around lines 11 - 28, The deferred file close in loadFromFile currently ignores the returned error which trips errcheck; update the defer to explicitly discard or handle the error from f.Close() (for example use defer func(){ _ = f.Close() }() or capture and log/return it) so that the close error is not ignored; change the defer f.Close() inside loadFromFile accordingly.
🤖 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.
Nitpick comments:
In `@pkg/runner/util.go`:
- Around line 11-28: The deferred file close in loadFromFile currently ignores
the returned error which trips errcheck; update the defer to explicitly discard
or handle the error from f.Close() (for example use defer func(){ _ = f.Close()
}() or capture and log/return it) so that the close error is not ignored; change
the defer f.Close() inside loadFromFile accordingly.
Proposed changes
Fixes #1790
Two bugs fixed in
pkg/runner/util.go:1. Replaced
fileutil.ReadFile(channel-based, goroutine errors not propagatable) withbufio.Scanner+os.Open.scanner.Err()is now returned so any I/O error during mid-read is surfaced to the caller instead of silently producing a partial list.2.
preprocessDomainnow stripshttps://andhttp://prefixes and truncates at the first/,?, or#. This prevents malformed entries likehttps://8.8.8.8in resolver/domain list files from silently failing inside dnsx.Minor: added
make([]string, 0, 64)to reduce reallocs on large input files.Proof
echo "https://8.8.8.8" > resolvers.txt
subfinder -d example.com -rL resolvers.txt -v
Before: resolver passed as-is, silently unused, no error shown.
After: entry normalized to
8.8.8.8, resolver used correctly.Checklist
Summary by CodeRabbit