fix: remove redundant io.Writer type annotation (staticcheck QF1011)#2780
fix: remove redundant io.Writer type annotation (staticcheck QF1011)#2780
Conversation
GetWriter() already returns io.Writer, making the explicit type annotation redundant. Remove it and the unused io import. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Removes a redundant compile-time io.Writer assignment in the logger tests that was triggering staticcheck QF1011, and replaces it with a runtime non-nil assertion.
Changes:
- Dropped the unused
ioimport frominternal/logger/file_logger_test.go. - Replaced
var _ io.Writer = logger.GetWriter()withw := logger.GetWriter()plus arequire.NotNilassertion.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| t.Run("GetWriter implements io.Writer interface", func(t *testing.T) { | ||
| tmpDir := t.TempDir() | ||
| logDir := filepath.Join(tmpDir, "logs") | ||
|
|
||
| err := InitFileLogger(logDir, "writer-test.log") | ||
| require.NoError(t, err) | ||
| defer CloseGlobalLogger() | ||
|
|
||
| globalLoggerMu.RLock() | ||
| logger := globalFileLogger | ||
| globalLoggerMu.RUnlock() | ||
|
|
||
| require.NotNil(t, logger) | ||
| var _ io.Writer = logger.GetWriter() | ||
| w := logger.GetWriter() | ||
| require.NotNil(t, w) |
There was a problem hiding this comment.
The subtest name "GetWriter implements io.Writer interface" is no longer accurate/meaningful: after removing the compile-time interface assignment, it only asserts the returned writer is non-nil, which is already guaranteed by (and effectively covered in) the earlier subtests that assert *os.File / os.Stdout. Consider removing this subtest entirely or repurposing it to verify behavior that isn’t already covered (e.g., that the returned writer can be used for a write).
Summary
Fixes staticcheck QF1011 lint warning in
internal/logger/file_logger_test.go.GetWriter()already returnsio.Writer, makingvar _ io.Writer = logger.GetWriter()redundant. Replaced with a simple call +require.NotNilassertion and removed the unusedioimport.Verification
make agent-finished✅ — all lint, build, and tests pass.