Skip to content

Commit 018dadd

Browse files
[+] bump golangci/golangci-lint-action from 6 to 7 (#679)
* Bump golangci/golangci-lint-action from 6 to 7 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6 to 7. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@v6...v7) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * migrate .golangci.yml to v2 * fix linter warnings * fix tests --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pavlo Golub <[email protected]>
1 parent 8c70f94 commit 018dadd

File tree

10 files changed

+47
-35
lines changed

10 files changed

+47
-35
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ jobs:
128128
go version
129129
130130
- name: GolangCI-Lint
131-
uses: golangci/golangci-lint-action@v6
131+
uses: golangci/golangci-lint-action@v7
132132
with:
133133
version: latest
134134

.golangci.yml

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1+
version: "2"
12
linters:
23
enable:
34
- gocyclo
45
- misspell
56
- revive
6-
7-
linters-settings:
8-
gocyclo:
9-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
10-
min-complexity: 15
11-
12-
issues:
13-
# List of regexps of issue texts to exclude, empty list by default.
14-
# But independently from this option we use default exclude patterns,
15-
# it can be disabled by `exclude-use-default: false`. To list all
16-
# excluded by default patterns execute `golangci-lint run --help`
17-
exclude:
18-
- SA5008 # ignore staticcheck for go-flags
7+
settings:
8+
gocyclo:
9+
min-complexity: 15
10+
exclusions:
11+
generated: lax
12+
presets:
13+
- comments
14+
- common-false-positives
15+
- legacy
16+
- std-error-handling
17+
rules:
18+
- path: (.+)\.go$
19+
text: SA5008 # ignore staticcheck for go-flags
20+
paths:
21+
- third_party$
22+
- builtin$
23+
- examples$
24+
formatters:
25+
exclusions:
26+
generated: lax
27+
paths:
28+
- third_party$
29+
- builtin$
30+
- examples$

internal/config/config.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,22 @@ func eachOption(g *flags.Group, f func(*flags.Group, *flags.Option)) {
5353
// VisitAll will execute fn() for all options found in command line.
5454
// Since we have only two level of nesting it's enough to use simplified group-prefixed name.
5555
func (cmdSet cmdArgSet) VisitAll(fn func(viper.FlagValue)) {
56-
root := cmdSet.Parser.Group.Find("Application Options")
56+
root := cmdSet.Group.Find("Application Options")
5757
eachOption(root, func(g *flags.Group, o *flags.Option) {
5858
name := o.LongName
5959
if g != root {
60-
name = g.ShortDescription + cmdSet.Parser.NamespaceDelimiter + name
60+
name = g.ShortDescription + cmdSet.NamespaceDelimiter + name
6161
}
6262
fn(cmdArg{name, o})
6363
})
6464
}
6565

6666
func (cmdSet cmdArgSet) setDefaults(v *viper.Viper) {
67-
eachOption(cmdSet.Parser.Group, func(g *flags.Group, o *flags.Option) {
67+
eachOption(cmdSet.Group, func(g *flags.Group, o *flags.Option) {
6868
if o.Default != nil && o.IsSetDefault() {
6969
name := o.LongName
70-
if g != cmdSet.Parser.Group {
71-
name = g.ShortDescription + cmdSet.Parser.NamespaceDelimiter + name
70+
if g != cmdSet.Group {
71+
name = g.ShortDescription + cmdSet.NamespaceDelimiter + name
7272
}
7373
v.SetDefault(name, o.Value())
7474
}
@@ -91,12 +91,12 @@ func NewConfig(writer io.Writer) (*CmdOptions, error) {
9191
v.SetConfigFile(v.GetString("config"))
9292
err := v.ReadInConfig() // Find and read the config file
9393
if err != nil { // Handle errors reading the config file
94-
return nil, fmt.Errorf("Fatal error reading config file: %w", err)
94+
return nil, fmt.Errorf("fatal error reading config file: %w", err)
9595
}
9696
}
9797
conf := &CmdOptions{}
9898
if err = v.Unmarshal(conf); err != nil {
99-
return nil, fmt.Errorf("Fatal error unmarshalling config file: %w", err)
99+
return nil, fmt.Errorf("fatal error unmarshalling config file: %w", err)
100100
}
101101
if conf.ClientName == "" {
102102
buf := bytes.NewBufferString("The required flag `-c, --clientname` was not specified\n")

internal/pgengine/bootstrap.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func NewDB(DB PgxPoolIface, args ...string) *PgEngine {
135135
}
136136

137137
func quoteIdent(s string) string {
138-
return `"` + strings.Replace(s, `"`, `""`, -1) + `"`
138+
return `"` + strings.ReplaceAll(s, `"`, `""`) + `"`
139139
}
140140

141141
// getPgxConnConfig transforms standard connestion string to pgx specific one with
@@ -230,7 +230,7 @@ func (pge *PgEngine) TryLockClientName(ctx context.Context, conn QueryRowIface)
230230
if e := conn.QueryRow(ctx, sql, pge.Getsid(), pge.ClientName).Scan(&locked); e != nil {
231231
return e
232232
} else if !locked {
233-
return errors.New("Cannot obtain lock for a session")
233+
return errors.New("cannot obtain lock for a session")
234234
}
235235
return nil
236236
}
@@ -240,12 +240,12 @@ func (pge *PgEngine) ExecuteCustomScripts(ctx context.Context, filename ...strin
240240
for _, f := range filename {
241241
sql, err := os.ReadFile(f)
242242
if err != nil {
243-
pge.l.WithError(err).Error("Cannot read command file")
243+
pge.l.WithError(err).Error("cannot read command file")
244244
return err
245245
}
246246
pge.l.Info("Executing script: ", f)
247247
if _, err = pge.ConfigDb.Exec(ctx, string(sql)); err != nil {
248-
pge.l.WithError(err).Error("Script execution failed")
248+
pge.l.WithError(err).Error("script execution failed")
249249
return err
250250
}
251251
pge.l.Info("Script file executed: ", f)

internal/pgengine/notification.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ func (pge *PgEngine) NotificationHandler(c *pgconn.PgConn, n *pgconn.Notificatio
6363
pge.chainSignalChan <- signal
6464
return
6565
}
66-
err = fmt.Errorf("Unknown chain ID: %d", signal.ConfigID)
66+
err = fmt.Errorf("unknown chain ID: %d", signal.ConfigID)
6767
default:
68-
err = fmt.Errorf("Unknown command: %s", signal.Command)
68+
err = fmt.Errorf("unknown command: %s", signal.Command)
6969
}
7070
}
71-
l.WithError(err).Error("Syntax error in payload")
71+
l.WithError(err).Error("syntax error in payload")
7272
}
7373

7474
// WaitForChainSignal returns configuration id from the notifications

internal/scheduler/chain.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (sch *Scheduler) processAsyncChain(ctx context.Context, chainSignal ChainSi
6262
case "START":
6363
var c Chain
6464
if err := sch.pgengine.SelectChain(ctx, &c, chainSignal.ConfigID); err != nil {
65-
return fmt.Errorf("Cannot start chain with ID: %d; %w", chainSignal.ConfigID, err)
65+
return fmt.Errorf("cannot start chain with ID: %d; %w", chainSignal.ConfigID, err)
6666
}
6767
go func() {
6868
select {
@@ -77,7 +77,7 @@ func (sch *Scheduler) processAsyncChain(ctx context.Context, chainSignal ChainSi
7777
cancel()
7878
return nil
7979
}
80-
return fmt.Errorf("Cannot stop chain with ID: %d. No running chain found", chainSignal.ConfigID)
80+
return fmt.Errorf("cannot stop chain with ID: %d. No running chain found", chainSignal.ConfigID)
8181
}
8282
return nil
8383
}

internal/scheduler/shell.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func (sch *Scheduler) ExecuteProgramCommand(ctx context.Context, command string,
3030

3131
command = strings.TrimSpace(command)
3232
if command == "" {
33-
return -1, "", errors.New("Program command cannot be empty")
33+
return -1, "", errors.New("program command cannot be empty")
3434
}
3535
if len(paramValues) == 0 { //mimic empty param
3636
paramValues = []string{""}
@@ -50,7 +50,7 @@ func (sch *Scheduler) ExecuteProgramCommand(ctx context.Context, command string,
5050
if err != nil {
5151
//check if we're dealing with an ExitError - i.e. return code other than 0
5252
if exitError, ok := err.(*exec.ExitError); ok {
53-
exitCode := exitError.ProcessState.ExitCode()
53+
exitCode := exitError.ExitCode()
5454
l.WithField("retcode", exitCode).Debug("Program run", cmdLine, exitCode)
5555
return exitCode, stdout, exitError
5656
}

internal/scheduler/shell_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestShellCommand(t *testing.T) {
3939
ctx := context.Background()
4040

4141
_, _, err = scheduler.ExecuteProgramCommand(ctx, "", []string{""})
42-
assert.EqualError(t, err, "Program command cannot be empty", "Empty command should out, fail")
42+
assert.EqualError(t, err, "program command cannot be empty", "Empty command should out, fail")
4343

4444
_, out, err = scheduler.ExecuteProgramCommand(ctx, "ping0", nil)
4545
assert.NoError(t, err, "Command with nil param is out, OK")

internal/scheduler/tasks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func taskDownload(ctx context.Context, _ *Scheduler, paramValues string) (stdout
117117
return "", err
118118
}
119119
if len(opts.FileUrls) == 0 {
120-
return "", errors.New("Files to download are not specified")
120+
return "", errors.New("files to download are not specified")
121121
}
122122
return tasks.DownloadUrls(ctx, opts.FileUrls, opts.DestPath, opts.WorkersNum)
123123
}

internal/scheduler/tasks_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func TestExecuteTask(t *testing.T) {
4343

4444
assert.Error(t, et("Download", []string{"foo"}), "Invalid json")
4545
assert.EqualError(t, et("Download", []string{`{"workersnum": 0, "fileurls": [] }`}),
46-
"Files to download are not specified", "Download with empty files should fail")
46+
"files to download are not specified", "Download with empty files should fail")
4747
assert.Error(t, et("Download", []string{`{"workersnum": 0, "fileurls": ["http://foo.bar"], "destpath": "" }`}),
4848
"Downlod incorrect url should fail")
4949

0 commit comments

Comments
 (0)