Skip to content

Commit 338521a

Browse files
committed
fix all lint issues
1 parent 98434d7 commit 338521a

13 files changed

Lines changed: 27 additions & 29 deletions

File tree

.golangci.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ linters:
6262
- exptostd # detects functions from golang.org/x/exp/ that can be replaced by std functions
6363
- fatcontext # detects nested contexts in loops
6464
- forbidigo # forbids identifiers
65-
- funcorder # checks the order of functions, methods, and constructors
6665
- funlen # tool for detection of long functions
6766
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
6867
- gochecknoglobals # checks that no global variables exist
@@ -258,11 +257,6 @@ linters:
258257
- ^google.golang.org/protobuf/.+Options$
259258
- ^gopkg.in/yaml.v3.Node$
260259

261-
funcorder:
262-
# Checks if the exported methods of a structure are placed before the non-exported ones.
263-
# Default: true
264-
struct-method: false
265-
266260
funlen:
267261
# Checks the number of lines in a function.
268262
# If lower than 0, disable the check.
@@ -434,14 +428,15 @@ linters:
434428
- text: 'comment on exported \S+ \S+ should be of the form ".+"'
435429
source: '// ?(nolint|TODO)'
436430
linters: [ revive, staticcheck ]
437-
- path: '_test\.go'
431+
- path: '(_test\.go|test_helpers\.go)'
438432
linters:
439433
- bodyclose
440434
- dupl
441435
- errcheck
442436
- funlen
443437
- goconst
444438
- gosec
439+
- govet
445440
- noctx
446441
- wrapcheck
447442
- gocognit

cmd/meeseeks/exit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ func exitCommand(args []string) error {
4141
if err != nil {
4242
return err
4343
}
44-
44+
//nolint:sloglint //currently working on adding support for custom logger
4545
slog.Info("Exiting meeseeks")
4646

4747
return nil
48-
}
48+
}

cmd/meeseeks/logs.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ func logsCommand(args []string) error {
4242
fmt.Fprintln(os.Stdout, string(data))
4343

4444
return nil
45-
}
45+
}

cmd/meeseeks/main_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"time"
88
)
99

10-
1110
func TestMainCommands(t *testing.T) {
1211
tests := []struct {
1312
name string

cmd/meeseeks/run.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ func runCommand(args []string) error {
5353
}
5454

5555
func runDetached(pidFile, configFile string, cfg *config.Config) error {
56+
//nolint:gosec // the arguments are provided by the user
5657
cmd := exec.Command(os.Args[0], "run", "-config", configFile)
5758
cmd.Env = os.Environ()
5859
cmd.SysProcAttr = &syscall.SysProcAttr{
@@ -62,6 +63,7 @@ func runDetached(pidFile, configFile string, cfg *config.Config) error {
6263
cmd.Stdin = nil
6364
stdoutFile, stdoutErr := getInternalStdoutFile()
6465
if stdoutErr != nil {
66+
//nolint:sloglint //currently working on adding support for custom logger
6567
slog.Warn("Failed to create log file for meeseeks, using /dev/null", "error", stdoutErr.Error())
6668
cmd.Stdout = nil
6769
cmd.Stderr = nil
@@ -77,6 +79,7 @@ func runDetached(pidFile, configFile string, cfg *config.Config) error {
7779
return fmt.Errorf("failed to write PID file: %w", err)
7880
}
7981

82+
//nolint:sloglint //currently working on adding support for custom logger
8083
slog.Info("Started meeseeks (detached)", "pid", cmd.Process.Pid, "program_count", len(cfg.Programs))
8184

8285
_ = cmd.Process.Release()
@@ -96,18 +99,20 @@ func runForeground(cfg *config.Config, sockPath, pidFile string) error {
9699
go func() {
97100
slog.Info("Started meeseeks", "program_count", len(cfg.Programs))
98101

99-
if err := s.Wait(ctx); err != nil {
100-
slog.Warn("Wait completed with error", "error", err)
102+
if waitErr := s.Wait(ctx); waitErr != nil {
103+
slog.Warn("Wait completed with error", "error", waitErr)
101104
}
102105
}()
103106

104107
sigChan := make(chan os.Signal, 1)
105108
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)
106109

107110
<-sigChan
111+
//nolint:sloglint //currently working on adding support for custom logger
108112
slog.Info("Received signal, shutting down...")
109113
err = s.Stop()
110114
if err != nil {
115+
//nolint:sloglint //currently working on adding support for custom logger
111116
slog.Warn("Error stopping the server.", "error", err.Error())
112117
}
113118
_ = os.Remove(pidFile)

cmd/meeseeks/run_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,18 @@ func TestRunCommand_Detached(t *testing.T) {
242242
t.Error("Socket file still exists. Stoping meeseeks should remove the Socket file")
243243
}
244244

245-
var stdoutBuf_2, stderrBuf_2 bytes.Buffer
245+
var stdoutBuf2, stderrBuf2 bytes.Buffer
246246
exitCode = runCLICommand(
247247
t,
248248
[]string{"status"},
249-
&stdoutBuf_2,
250-
&stderrBuf_2,
249+
&stdoutBuf2,
250+
&stderrBuf2,
251251
5*time.Second,
252252
)
253253
if exitCode != 1 {
254254
t.Errorf("Expected exit code %d, got %d", 1, exitCode)
255255
}
256-
statusOutput = stdoutBuf_2.String() + stderrBuf_2.String()
256+
statusOutput = stdoutBuf2.String() + stderrBuf2.String()
257257

258258
if !strings.Contains(statusOutput, "meeseeks server not running") {
259259
t.Error("Status command should not work after exiting meeseeks")

cmd/meeseeks/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func statusCommand(args []string) error {
4747
data, _ := json.MarshalIndent(resp.Data, "", " ")
4848
fmt.Fprintln(os.Stdout, string(data))
4949
} else {
50-
if err := formatStatisticsAsTable(resp.Data, programName); err != nil {
50+
if err = formatStatisticsAsTable(resp.Data, programName); err != nil {
5151
return err
5252
}
5353
}

cmd/meeseeks/status_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ test-echo-detached 1 0 0 1 no running`,
3131
name: "status format json",
3232
args: []string{"status", "-f", "json"},
3333
expectedExit: 0,
34-
shouldContain: `"ProgramName": "test-echo-detached"`,
34+
shouldContain: `"program_name": "test-echo-detached"`,
3535
},
3636
{
3737
name: "status format json single program",
3838
args: []string{"status", "-f", "json", "test-echo-detached"},
3939
expectedExit: 0,
40-
shouldContain: `"ProgramName": "test-echo-detached"`,
40+
shouldContain: `"program_name": "test-echo-detached"`,
4141
},
4242
{
4343
name: "status non existing program",

cmd/meeseeks/stop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ func stopCommand(args []string) error {
3636

3737
fmt.Fprintln(os.Stdout, "Stop command executed")
3838
return nil
39-
}
39+
}

cmd/meeseeks/stop_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func TestStopCommand_Validation(t *testing.T) {
2626
}
2727

2828
func TestStopCommand(t *testing.T) {
29-
3029
configContent := `programs:
3130
- name: "test-stop-program1"
3231
command: "sleep"

0 commit comments

Comments
 (0)