diff --git a/.golangci.yml b/.golangci.yml index 390fd68eb9b..d78da73f9de 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -29,6 +29,9 @@ issues: text: "does not use range value in test Run" 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: diff --git a/cloudapi/config.go b/cloudapi/config.go index ef3dd3d273a..1868d2e7833 100644 --- a/cloudapi/config.go +++ b/cloudapi/config.go @@ -31,7 +31,7 @@ import ( ) // Config holds all the necessary data and options for sending metrics to the Load Impact cloud. -//nolint: lll +//nolint:lll type Config struct { // TODO: refactor common stuff between cloud execution and output Token null.String `json:"token" envconfig:"K6_CLOUD_TOKEN"` diff --git a/cmd/cloud.go b/cmd/cloud.go index ad0f4be69cf..3d272b09a41 100644 --- a/cmd/cloud.go +++ b/cmd/cloud.go @@ -82,7 +82,7 @@ func (c *cmdCloud) preRun(cmd *cobra.Command, args []string) error { } // TODO: split apart some more -// nolint: funlen,gocognit,cyclop +//nolint:funlen,gocognit,cyclop func (c *cmdCloud) run(cmd *cobra.Command, args []string) error { printBanner(c.gs) diff --git a/cmd/login_cloud.go b/cmd/login_cloud.go index 5f3ff82d5cb..dab320e84da 100644 --- a/cmd/login_cloud.go +++ b/cmd/login_cloud.go @@ -104,7 +104,7 @@ This will set the default token used when just "k6 run -o cloud" is passed.`, }, }, } - if !term.IsTerminal(int(syscall.Stdin)) { // nolint: unconvert + if !term.IsTerminal(int(syscall.Stdin)) { //nolint:unconvert globalState.logger.Warn("Stdin is not a terminal, falling back to plain text input") } var vals map[string]string diff --git a/cmd/login_influxdb.go b/cmd/login_influxdb.go index 4f34021fada..61f9efc5a77 100644 --- a/cmd/login_influxdb.go +++ b/cmd/login_influxdb.go @@ -89,7 +89,7 @@ This will set the default server used when just "-o influxdb" is passed.`, }, }, } - if !term.IsTerminal(int(syscall.Stdin)) { // nolint: unconvert + if !term.IsTerminal(int(syscall.Stdin)) { //nolint:unconvert globalState.logger.Warn("Stdin is not a terminal, falling back to plain text input") } vals, err := form.Run(globalState.stdIn, globalState.stdOut) diff --git a/cmd/ui.go b/cmd/ui.go index dc20f19636a..295b8f3e00d 100644 --- a/cmd/ui.go +++ b/cmd/ui.go @@ -198,7 +198,7 @@ func printExecutionDescription( } } -//nolint: funlen +//nolint:funlen func renderMultipleBars( nocolor, isTTY, goBack bool, maxLeft, termWidth, widthDelta int, pbs []*pb.ProgressBar, ) (string, int) { @@ -291,7 +291,7 @@ func renderMultipleBars( // TODO: show other information here? // TODO: add a no-progress option that will disable these // TODO: don't use global variables... -// nolint:funlen,gocognit +//nolint:funlen,gocognit func showProgress(ctx context.Context, gs *globalState, pbs []*pb.ProgressBar, logger *logrus.Logger) { if gs.flags.quiet { return diff --git a/core/engine_test.go b/core/engine_test.go index 2ee88f43ab6..1dd96aa4ef7 100644 --- a/core/engine_test.go +++ b/core/engine_test.go @@ -254,7 +254,7 @@ func TestEngineOutput(t *testing.T) { } metric := test.engine.MetricsEngine.ObservedMetrics["test_metric"] if assert.NotNil(t, metric) { - sink := metric.Sink.(*metrics.TrendSink) // nolint: forcetypeassert + sink := metric.Sink.(*metrics.TrendSink) //nolint:forcetypeassert if assert.NotNil(t, sink) { numOutputSamples := len(cSamples) numEngineSamples := len(sink.Values) @@ -1153,7 +1153,6 @@ func TestMetricsEmission(t *testing.T) { } } -//nolint: funlen func TestMinIterationDurationInSetupTeardownStage(t *testing.T) { t.Parallel() setupScript := ` diff --git a/errext/exitcodes/codes.go b/errext/exitcodes/codes.go index d7ed6be213a..18da50b350c 100644 --- a/errext/exitcodes/codes.go +++ b/errext/exitcodes/codes.go @@ -19,7 +19,7 @@ */ // Package exitcodes contains the constants representing possible k6 exit error codes. -//nolint: golint +//nolint:golint package exitcodes // ExitCode is just a type representing a process exit code for k6 diff --git a/js/common/bridge.go b/js/common/bridge.go index dc379b7155b..c7fbcba1223 100644 --- a/js/common/bridge.go +++ b/js/common/bridge.go @@ -9,7 +9,7 @@ import ( // if a fieldName is the key of this map exactly than the value for the given key should be used as // the name of the field in js -//nolint: gochecknoglobals +//nolint:gochecknoglobals var fieldNameExceptions = map[string]string{ "OCSP": "ocsp", } @@ -41,7 +41,7 @@ func FieldName(t reflect.Type, f reflect.StructField) string { // if a methodName is the key of this map exactly than the value for the given key should be used as // the name of the method in js -//nolint: gochecknoglobals +//nolint:gochecknoglobals var methodNameExceptions = map[string]string{ "JSON": "json", "HTML": "html", diff --git a/js/compiler/compiler.go b/js/compiler/compiler.go index 01cdb94b1c7..29e4af859bd 100644 --- a/js/compiler/compiler.go +++ b/js/compiler/compiler.go @@ -88,11 +88,11 @@ var ( maxSrcLenForBabelSourceMap = 250 * 1024 //nolint:gochecknoglobals maxSrcLenForBabelSourceMapOnce sync.Once //nolint:gochecknoglobals - onceBabelCode sync.Once // nolint:gochecknoglobals - globalBabelCode *goja.Program // nolint:gochecknoglobals - globalBabelCodeErr error // nolint:gochecknoglobals - onceBabel sync.Once // nolint:gochecknoglobals - globalBabel *babel // nolint:gochecknoglobals + onceBabelCode sync.Once //nolint:gochecknoglobals + globalBabelCode *goja.Program //nolint:gochecknoglobals + errGlobalBabelCode error //nolint:gochecknoglobals + onceBabel sync.Once //nolint:gochecknoglobals + globalBabel *babel //nolint:gochecknoglobals ) const ( @@ -265,10 +265,10 @@ type babel struct { func newBabel() (*babel, error) { onceBabelCode.Do(func() { - globalBabelCode, globalBabelCodeErr = goja.Compile("", babelSrc, false) + globalBabelCode, errGlobalBabelCode = goja.Compile("", babelSrc, false) }) - if globalBabelCodeErr != nil { - return nil, globalBabelCodeErr + if errGlobalBabelCode != nil { + return nil, errGlobalBabelCode } vm := goja.New() _, err := vm.RunProgram(globalBabelCode) diff --git a/js/module_loading_test.go b/js/module_loading_test.go index 001b42ab1c7..88bd309786f 100644 --- a/js/module_loading_test.go +++ b/js/module_loading_test.go @@ -444,7 +444,6 @@ func TestLoadCycleBinding(t *testing.T) { func TestBrowserified(t *testing.T) { t.Parallel() fs := afero.NewMemMapFs() - //nolint: lll require.NoError(t, afero.WriteFile(fs, "/browserified.js", []byte(` (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.npmlibs = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i