-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consume returned values implicitly, remove some nolint comments #410
Changes from all commits
4745782
f707deb
09cefde
290befe
a834b85
7ba6a23
a022c00
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ func awaitAdminAddress(sigCtx context.Context, r *Runtime) { | |
for i := 0; i < 10 && sigCtx.Err() == nil; i++ { | ||
adminAddress, adminErr := r.GetAdminAddress() | ||
if adminErr == nil { | ||
moreos.Fprintf(r.Out, "discovered admin address: %s\n", adminAddress) //nolint | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. odd this passes lint (via |
||
moreos.Fprintf(r.Out, "discovered admin address: %s\n", adminAddress) | ||
return | ||
} | ||
time.Sleep(200 * time.Millisecond) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,19 +160,15 @@ func parseProc(ctx context.Context, p *process.Process) (*proc, error) { | |
func printProcessTable(out io.Writer, parsed []*proc) error { | ||
// Now, start writing the process table | ||
w := tabwriter.NewWriter(out, 0, 8, 5, ' ', 0) | ||
if _, err := moreos.Fprintf(w, "PID\tUSERNAME\tSTATUS\tRSS\tVSZ\tMINFLT\tMAJFLT\tPCPU\tPMEM\tARGS\n"); err != nil { | ||
return err | ||
} | ||
moreos.Fprintf(w, "PID\tUSERNAME\tSTATUS\tRSS\tVSZ\tMINFLT\tMAJFLT\tPCPU\tPMEM\tARGS\n") | ||
|
||
for _, p := range parsed { | ||
status := "" | ||
if len(p.status) > 0 { | ||
status = p.status[0] | ||
} | ||
if _, err := moreos.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%.2f\t%.2f\t%v\n", | ||
p.pid, p.username, status, p.rss, p.vms, p.minflt, p.majflt, p.pCPU, p.pMem, p.cmd); err != nil { | ||
return err | ||
} | ||
moreos.Fprintf(w, "%v\t%v\t%v\t%v\t%v\t%v\t%v\t%.2f\t%.2f\t%v\n", | ||
p.pid, p.username, status, p.rss, p.vms, p.minflt, p.majflt, p.pCPU, p.pMem, p.cmd) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cool this is easier to read and chance of error writing stdout isn't high |
||
} | ||
return w.Flush() | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,11 +95,13 @@ func Sprintf(format string, a ...interface{}) string { | |
} | ||
|
||
// Fprintf is like fmt.Fprintf, but handles EOL according runtime.GOOS. See Sprintf for notes. | ||
func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { | ||
func Fprintf(w io.Writer, format string, a ...interface{}) { | ||
if runtime.GOOS != OSWindows { | ||
return fmt.Fprintf(w, format, a...) | ||
_, _ = fmt.Fprintf(w, format, a...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair enough to do this here vs |
||
return | ||
} | ||
return fmt.Fprint(w, Sprintf(format, a...)) | ||
|
||
_, _ = fmt.Fprint(w, Sprintf(format, a...)) | ||
} | ||
|
||
// ProcessGroupAttr sets attributes that ensure exec.Cmd doesn't propagate signals from func-e by default. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,16 +102,14 @@ func TestSprintf(t *testing.T) { | |
func TestFprintf(t *testing.T) { | ||
template := "%s\n\n%s\n" | ||
stdout := new(bytes.Buffer) | ||
count, err := Fprintf(stdout, template, "foo", "bar") | ||
require.NoError(t, err) | ||
Fprintf(stdout, template, "foo", "bar") | ||
|
||
expected := "foo\n\nbar\n" | ||
if runtime.GOOS == OSWindows { | ||
expected = "foo\r\n\r\nbar\r\n" | ||
} | ||
|
||
require.Equal(t, expected, stdout.String()) | ||
require.Equal(t, len(expected), count) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep, this is no longer possible to check, but wasn't used either! |
||
} | ||
|
||
// TestSprintf_IdiomaticPerOS is here to ensure that the EOL translation makes sense. For example, in UNIX, we expect | ||
|
@@ -140,7 +138,7 @@ func TestProcessGroupAttr_Interrupt(t *testing.T) { | |
require.NoError(t, Interrupt(cmd.Process)) | ||
|
||
// Wait for the process to die; this could error due to the interrupt signal | ||
cmd.Wait() //nolint | ||
_ = cmd.Wait() | ||
require.Error(t, findProcess(cmd.Process)) | ||
|
||
// Ensure interrupting it again doesn't error | ||
|
@@ -157,7 +155,7 @@ func Test_EnsureProcessDone(t *testing.T) { | |
require.NoError(t, EnsureProcessDone(cmd.Process)) | ||
|
||
// Wait for the process to die; this could error due to the kill signal | ||
cmd.Wait() //nolint | ||
_ = cmd.Wait() | ||
require.Error(t, findProcess(cmd.Process)) | ||
|
||
// Ensure killing it again doesn't error | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,7 @@ func (s *server) funcEVersions() []byte { | |
} | ||
|
||
// RequireFakeEnvoyTarGz makes a fake envoy.tar.gz | ||
//nolint:gosec | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is test-only, so ok |
||
func RequireFakeEnvoyTarGz(t *testing.T, v version.PatchVersion) ([]byte, version.SHA256Sum) { | ||
tempDir := t.TempDir() | ||
|
||
|
@@ -124,9 +125,9 @@ func RequireFakeEnvoyTarGz(t *testing.T, v version.PatchVersion) ([]byte, versio | |
require.NoError(t, err) | ||
|
||
// Read the tar.gz into a byte array. This allows the mock server to set content length correctly | ||
f, err := os.Open(tempGz) //nolint:gosec | ||
f, err := os.Open(tempGz) | ||
require.NoError(t, err) | ||
defer f.Close() // nolint | ||
defer f.Close() //nolint | ||
b, err := io.ReadAll(f) | ||
require.NoError(t, err) | ||
return b, version.SHA256Sum(fmt.Sprintf("%x", sha256.Sum256(b))) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ack, this neither trips golint nor goland!