Skip to content

Commit

Permalink
feat: Linter and linter configuration update according to the update …
Browse files Browse the repository at this point in the history
…in k6.
  • Loading branch information
szkiba committed May 21, 2024
1 parent ee65dd4 commit dfb2650
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 16 deletions.
16 changes: 7 additions & 9 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# v1.55.2
# v1.57.2
# Please don't remove the first line. It uses in CI to determine the golangci version
run:
deadline: 5m
timeout: 5m

issues:
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
Expand All @@ -24,6 +24,11 @@ issues:
- gocognit
- funlen
- lll
- forcetypeassert
- path: js\/modules\/k6\/html\/.*\.go
text: "exported: exported "
linters:
- revive
- path: js\/modules\/k6\/http\/.*_test\.go
linters:
# k6/http module's tests are quite complex because they often have several nested levels.
Expand All @@ -38,17 +43,10 @@ issues:
text: 'use of `os\.(SyscallError|Signal|Interrupt)` forbidden'

linters-settings:
nolintlint:
# Disable to ensure that nolint directives don't have a leading space. Default is true.
allow-leading-space: false
exhaustive:
default-signifies-exhaustive: true
govet:
check-shadowing: true
cyclop:
max-complexity: 25
maligned:
suggest-new: true
dupl:
threshold: 150
goconst:
Expand Down
6 changes: 3 additions & 3 deletions dashboard/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func newReplayCommand(assets *assets, proc *process) *cobra.Command {
Long: `The replay command load the recorded dashboard events (NDJSON format) and replay it for the dashboard UI.
The compressed file will be automatically decompressed if the file extension is .gz`,
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
err := replay(args[0], opts, assets, proc)
if err != nil {
return err
Expand Down Expand Up @@ -107,7 +107,7 @@ func newAggregateCommand(proc *process) *cobra.Command {
Long: `The aggregate command converts the file saved by json output to dashboard format events file.
The files will be automatically compressed/decompressed if the file extension is .gz`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
return aggregate(args[0], args[1], opts, proc)
},
}
Expand Down Expand Up @@ -153,7 +153,7 @@ $ k6 ` + OutputName + ` replay test_result.ndjson
$ k6 run --out web-dashboard=record=test_result.ndjson script.js
$ k6 ` + OutputName + ` report test_result.ndjson test_result_report.html`,
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, args []string) error {
opts.Port = -1
opts.Export = args[1]

Expand Down
2 changes: 1 addition & 1 deletion dashboard/customize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func Test_customize(t *testing.T) {
assert.False(t, gjson.GetBytes(conf, `tabs.#(id="custom")`).Exists())
}

func Test_customize_env_found(t *testing.T) { //nolint:paralleltest
func Test_customize_env_found(t *testing.T) {
t.Setenv("XK6_DASHBOARD_CONFIG", "testdata/customize/config-custom.js")

th := helper(t).osFs()
Expand Down
2 changes: 1 addition & 1 deletion dashboard/extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func TestExtension_error_used_port(t *testing.T) {
assert.NoError(t, ext.Stop())
}

func TestExtension_open(t *testing.T) { //nolint:paralleltest
func TestExtension_open(t *testing.T) {
var params output.Params

params.Logger = logrus.StandardLogger()
Expand Down
2 changes: 1 addition & 1 deletion dashboard/meter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func Test_meter_add(t *testing.T) {
metric := met.registry.Get("foo")

assert.NotNil(t, metric)
assert.Equal(t, 1.0, metric.Sink.(*metrics.CounterSink).Value) //nolint:forcetypeassert
assert.Equal(t, 1.0, metric.Sink.(*metrics.CounterSink).Value)
}

func Test_meter_update_error(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion dashboard/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func Test_replay_gz(t *testing.T) {
assert.Equal(t, testdataEventLines, len(lines))
}

func Test_replay_open(t *testing.T) { //nolint:paralleltest
func Test_replay_open(t *testing.T) {
opts := &options{
Port: 0,
Host: "127.0.0.1",
Expand Down

0 comments on commit dfb2650

Please sign in to comment.