Skip to content

Commit

Permalink
chore: fixes reported by nolint
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Jul 10, 2023
1 parent 3fa7275 commit a5f0540
Show file tree
Hide file tree
Showing 18 changed files with 19 additions and 26 deletions.
1 change: 0 additions & 1 deletion cloudapi/insights/proto/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// by the k6 Insights.
package proto

//nolint:lll
//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./v1/common/common.proto
//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./v1/ingester/ingester.proto
//go:generate protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative ./v1/k6/labels.proto
Expand Down
2 changes: 1 addition & 1 deletion js/compiler/compiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

//go:embed lib/babel.min.js
var babelSrc string //nolint:gochecknoglobals
var babelSrc string

var (
DefaultOpts = map[string]interface{}{
Expand Down
6 changes: 3 additions & 3 deletions js/init_and_modules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ type CheckModule struct {
vuCtxCalled int
}

func (cm *CheckModule) InitCtx(ctx context.Context) {
func (cm *CheckModule) InitCtx(_ context.Context) {
cm.initCtxCalled++
}

func (cm *CheckModule) VuCtx(ctx context.Context) {
func (cm *CheckModule) VuCtx(_ context.Context) {
cm.vuCtxCalled++
}

var uniqueModuleNumber int64 //nolint // we need this so multiple test can register differently named modules
var uniqueModuleNumber int64 //nolint:gochecknoglobals // we need this so multiple test can register differently named modules

func TestNewJSRunnerWithCustomModule(t *testing.T) {
t.Parallel()
Expand Down
2 changes: 0 additions & 2 deletions js/modules/k6/http/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,11 @@ func TestResponse(t *testing.T) {

t.Run("Invalid", func(t *testing.T) {
_, err := rt.RunString(sr(`http.request("GET", "HTTPBIN_URL/html").json();`))
//nolint:lll
assert.Contains(t, err.Error(), "cannot parse json due to an error at line 1, character 2 , error: invalid character '<' looking for beginning of value")
})

t.Run("Invalid", func(t *testing.T) {
_, err := rt.RunString(sr(`http.request("GET", "HTTPBIN_URL/invalidjson").json();`))
//nolint:lll
assert.Contains(t, err.Error(), "cannot parse json due to an error at line 3, character 9 , error: invalid character 'e' in literal true (expecting 'r')")
})

Expand Down
2 changes: 0 additions & 2 deletions js/modules/k6/k6.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@ func (mi *K6) Group(name string, val goja.Value) (goja.Value, error) {
}

// Check will emit check metrics for the provided checks.
//
//nolint:cyclop
func (mi *K6) Check(arg0, checks goja.Value, extras ...goja.Value) (bool, error) {
state := mi.vu.State()
if state == nil {
Expand Down
4 changes: 2 additions & 2 deletions js/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
// Copied from https://github.com/k6io/jslib.k6.io/tree/master/lib/k6-summary
//
//go:embed summary.js
var jslibSummaryCode string //nolint:gochecknoglobals
var jslibSummaryCode string

//go:embed summary-wrapper.js
var summaryWrapperLambdaCode string //nolint:gochecknoglobals
var summaryWrapperLambdaCode string

// TODO: figure out something saner... refactor the sinks and how we deal with
// metrics in general... so much pain and misery... :sob:
Expand Down
4 changes: 2 additions & 2 deletions js/tc39/tc39_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func parseTC39File(name string) (*tc39Meta, string, error) {
if err != nil {
return nil, "", err
}
defer f.Close() //nolint:errcheck,gosec
defer f.Close() //nolint:errcheck

b, err := io.ReadAll(f)
if err != nil {
Expand Down Expand Up @@ -586,7 +586,7 @@ func (ctx *tc39TestCtx) compile(base, name string) (*goja.Program, error) {
if err != nil {
return nil, err
}
defer f.Close() //nolint:gosec,errcheck
defer f.Close() //nolint:errcheck

b, err := io.ReadAll(f)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion lib/executor/base_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import (
// TODO?: Discard? Or make this actually user-configurable somehow? hello #883...
var DefaultGracefulStopValue = 30 * time.Second //nolint:gochecknoglobals

var executorNameWhitelist = regexp.MustCompile(`^[0-9a-zA-Z_-]+$`) //nolint:gochecknoglobals
var executorNameWhitelist = regexp.MustCompile(`^[0-9a-zA-Z_-]+$`)

const executorNameErr = "the executor name should contain only numbers, latin letters, underscores, and dashes"

// BaseConfig contains the common config fields for all executors
Expand Down
2 changes: 1 addition & 1 deletion lib/executor/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type executorTest struct {
options lib.Options
state *lib.ExecutionState

ctx context.Context //nolint
ctx context.Context
cancel context.CancelFunc
executor lib.Executor
logHook *testutils.SimpleLogrusHook
Expand Down
2 changes: 1 addition & 1 deletion lib/executor/constant_arrival_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (car *ConstantArrivalRate) Init(ctx context.Context) error {
// This will allow us to implement https://github.com/k6io/k6/issues/1386
// and things like all of the TODOs below in one place only.
//
//nolint:funlen,cyclop
//nolint:funlen
func (car ConstantArrivalRate) Run(parentCtx context.Context, out chan<- metrics.SampleContainer) (err error) {
gracefulStop := car.config.GetGracefulStop()
duration := car.config.Duration.TimeDuration()
Expand Down
2 changes: 1 addition & 1 deletion lib/executor/constant_arrival_rate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func TestConstantArrivalRateRunCorrectRate(t *testing.T) {
require.Empty(t, test.logHook.Drain())
}

//nolint:tparallel,paralleltest // this is flaky if ran with other tests
//nolint:paralleltest // this is flaky if ran with other tests
func TestConstantArrivalRateRunCorrectTiming(t *testing.T) {
if runtime.GOOS == "windows" {
t.Skipf("this test is very flaky on the Windows GitHub Action runners...")
Expand Down
2 changes: 1 addition & 1 deletion lib/executor/ramping_arrival_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func noNegativeSqrt(f float64) float64 {
// This will allow us to implement https://github.com/k6io/k6/issues/1386
// and things like all of the TODOs below in one place only.
//
//nolint:funlen,cyclop
//nolint:funlen
func (varr RampingArrivalRate) Run(parentCtx context.Context, out chan<- metrics.SampleContainer) (err error) {
segment := varr.executionState.ExecutionTuple.Segment
gracefulStop := varr.config.GetGracefulStop()
Expand Down
1 change: 0 additions & 1 deletion lib/netext/httpext/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
// ResponseType is used in the request to specify how the response body should be treated
// The conversion and validation methods are auto-generated with https://github.com/alvaroloes/enumer:
//
//nolint:lll
//go:generate enumer -type=ResponseType -transform=snake -json -text -trimprefix ResponseType -output response_type_gen.go
type ResponseType uint

Expand Down
2 changes: 1 addition & 1 deletion lib/netext/httpext/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func newTransport(
// Helper method to finish the tracer trail, assemble the tag values and emits
// the metric samples for the supplied unfinished request.
//
//nolint:nestif,funlen
//nolint:funlen
func (t *transport) measureAndEmitMetrics(unfReq *unfinishedRequest) *finishedRequest {
trail := unfReq.tracer.Done()

Expand Down
1 change: 0 additions & 1 deletion lib/runtime_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

// CompatibilityMode specifies the JS compatibility mode
//
//nolint:lll
//go:generate enumer -type=CompatibilityMode -transform=snake -trimprefix CompatibilityMode -output compatibility_mode_gen.go
type CompatibilityMode uint8

Expand Down
6 changes: 3 additions & 3 deletions metrics/thresholds_parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestParseThresholdExpression(t *testing.T) {

func BenchmarkParseThresholdExpression(b *testing.B) {
for i := 0; i < b.N; i++ {
parseThresholdExpression("count>20") // nolint
_, _ = parseThresholdExpression("count>20")
}
}

Expand Down Expand Up @@ -203,7 +203,7 @@ func TestParseThresholdAggregationMethod(t *testing.T) {

func BenchmarkParseThresholdAggregationMethod(b *testing.B) {
for i := 0; i < b.N; i++ {
parseThresholdAggregationMethod("p(99.9)") // nolint
_, _, _ = parseThresholdAggregationMethod("p(99.9)")
}
}

Expand Down Expand Up @@ -336,6 +336,6 @@ func TestScanThresholdExpression(t *testing.T) {

func BenchmarkScanThresholdExpression(b *testing.B) {
for i := 0; i < b.N; i++ {
scanThresholdExpression("foo<=bar") // nolint
_, _, _, _ = scanThresholdExpression("foo<=bar")
}
}
2 changes: 1 addition & 1 deletion metrics/thresholds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func BenchmarkRunNoTaint(b *testing.B) {
b.ResetTimer()

for i := 0; i < b.N; i++ {
threshold.runNoTaint(sinks) // nolint
_, _ = threshold.runNoTaint(sinks)
}
}

Expand Down
1 change: 0 additions & 1 deletion output/statsd/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type getOutputFn func(
pushInterval types.NullDuration,
) (*Output, error)

//nolint:funlen
func baseTest(t *testing.T,
getOutput getOutputFn,
checkResult func(t *testing.T, samples []metrics.SampleContainer, expectedOutput, output string),
Expand Down

0 comments on commit a5f0540

Please sign in to comment.