From 5e1374946b7f4533febeba4206c3f178490b71e5 Mon Sep 17 00:00:00 2001 From: Leonardo Di Donato Date: Thu, 21 Mar 2024 00:53:58 +0100 Subject: [PATCH] ci: disable golangci-lint pkg cache temporarily See https://github.com/golangci/golangci-lint-action/issues/135 Signed-off-by: Leonardo Di Donato --- .github/workflows/lint.yml | 7 +++++-- cmd/in/in.go | 2 +- cmd/root/root.go | 4 ++-- cmd/version/version.go | 2 +- make/docs/main.go | 4 ++-- pkg/cmd/flags/base_test.go | 2 +- pkg/cmd/flags/config.go | 2 +- pkg/cmd/flags/json_test.go | 6 +++--- pkg/cmd/help/config.go | 2 +- pkg/cmd/help/environment.go | 2 +- pkg/cmd/help/manual.go | 2 +- pkg/cmd/help/reporters.go | 2 +- pkg/listen/types_test.go | 2 +- pkg/npm/types.go | 4 ++-- pkg/transform/transform.go | 2 +- 15 files changed, 24 insertions(+), 21 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index eb726323..319d60a9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -32,7 +32,7 @@ jobs: uses: actions/setup-go@v5 with: go-version: "1.21" - cache: false + check-latest: true - name: Verify the dependencies run: | @@ -42,6 +42,9 @@ jobs: - name: Lint uses: golangci/golangci-lint-action@v4 with: - version: v1.54 + version: v1.57.1 args: --timeout 20m0s --verbose --out-${IGNORE_FUTURE_WARNINGS}format tab only-new-issues: true # Show only new issues on pull requests + # Disable caching as a workaround for https://github.com/golangci/golangci-lint-action/issues/135. + # The line can be removed once the golangci-lint issue is resolved. + skip-pkg-cache: true diff --git a/cmd/in/in.go b/cmd/in/in.go index 3926b0e0..f6052998 100644 --- a/cmd/in/in.go +++ b/cmd/in/in.go @@ -95,7 +95,7 @@ The verdicts it returns are listed by the name of each package and its specified } // Fallback to reading the package-lock.json in the target directory if packageLockJSONErr != nil || !inOpts.GenerateLock { - packageLockJSON, packageLockJSONErr = npm.GetPackageLockJsonFromDir(targetDir) + packageLockJSON, packageLockJSONErr = npm.GetPackageLockJSONFromDir(targetDir) } if packageLockJSONErr != nil { return packageLockJSONErr diff --git a/cmd/root/root.go b/cmd/root/root.go index c520c030..17edf577 100644 --- a/cmd/root/root.go +++ b/cmd/root/root.go @@ -75,7 +75,7 @@ func New(ctx context.Context) (*Command, error) { Annotations: map[string]string{ "source": project.GetSourceURL(filename), }, - PersistentPreRunE: func(c *cobra.Command, args []string) error { + PersistentPreRunE: func(c *cobra.Command, _ []string) error { // Do not check for the config file if the command is not available (eg., help) or not core (eg., version) withConfigFile := false c, _, err := c.Find(os.Args[1:]) @@ -240,7 +240,7 @@ func New(ctx context.Context) (*Command, error) { return nil }, - PersistentPostRunE: func(c *cobra.Command, args []string) error { + PersistentPostRunE: func(c *cobra.Command, _ []string) error { contextCancel, ok := c.Context().Value(pkgcontext.ContextCancelFuncKey).(context.CancelFunc) if !ok { return fmt.Errorf("couldn't obtain configuration options") diff --git a/cmd/version/version.go b/cmd/version/version.go index 7273ee67..849f0104 100644 --- a/cmd/version/version.go +++ b/cmd/version/version.go @@ -39,7 +39,7 @@ func New(ctx context.Context) (*cobra.Command, error) { Annotations: map[string]string{ "source": project.GetSourceURL(filename), }, - RunE: func(c *cobra.Command, args []string) error { + RunE: func(c *cobra.Command, _ []string) error { ctx = c.Context() // Obtain the local options from the context diff --git a/make/docs/main.go b/make/docs/main.go index f9b17f6f..42df7d22 100644 --- a/make/docs/main.go +++ b/make/docs/main.go @@ -46,7 +46,7 @@ func getManpages(ctx context.Context) *cobra.Command { SilenceUsage: true, DisableFlagsInUseLine: true, Short: "Generate lstn manpages.", - RunE: func(c *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, _ []string) error { rootFlagValues, ok := ctx.Value(rootFlagsKey).(*rootFlags) if !ok { return fmt.Errorf("couldn't obtain the flag values from the context") @@ -68,7 +68,7 @@ func newRoot(ctx context.Context) error { SilenceUsage: true, Short: "Generate lstn documentation.", Args: cobra.ExactArgs(1), - PersistentPreRunE: func(c *cobra.Command, args []string) error { + PersistentPreRunE: func(_ *cobra.Command, _ []string) error { // Eventually validate rootF struct return nil diff --git a/pkg/cmd/flags/base_test.go b/pkg/cmd/flags/base_test.go index 2ca308c9..7f355dd5 100644 --- a/pkg/cmd/flags/base_test.go +++ b/pkg/cmd/flags/base_test.go @@ -103,7 +103,7 @@ func (suite *FlagsBaseSuite) TestValidate() { } for _, tc := range cases { - suite.T().Run(tc.desc, func(t *testing.T) { + suite.T().Run(tc.desc, func(_ *testing.T) { actual := Validate(tc.o) assert.Equal(suite.T(), len(tc.expectedStr), len(actual)) for _, a := range actual { diff --git a/pkg/cmd/flags/config.go b/pkg/cmd/flags/config.go index b4fa5ea7..0c34c3fc 100644 --- a/pkg/cmd/flags/config.go +++ b/pkg/cmd/flags/config.go @@ -107,7 +107,7 @@ func (o *ConfigFlags) SetDefaults() { } if defaults.CanUpdate(o.Reporting.Types) { // Create the enum flag value for --reporter - enumValues := goneric.MapToSlice(func(t cmd.ReportType, v []string) string { + enumValues := goneric.MapToSlice(func(_ cmd.ReportType, v []string) string { return v[0] }, cmd.ReporterTypeIDs) sort.Strings(enumValues) diff --git a/pkg/cmd/flags/json_test.go b/pkg/cmd/flags/json_test.go index 2eb911ee..be792914 100644 --- a/pkg/cmd/flags/json_test.go +++ b/pkg/cmd/flags/json_test.go @@ -45,21 +45,21 @@ func (suite *FlagsJSONSuite) TestQuery() { } func (suite *FlagsJSONSuite) TestOutput() { - suite.T().Run("Failure", func(t *testing.T) { + suite.T().Run("Failure", func(_ *testing.T) { i := &JSONFlags{JSON: false, JQ: "."} input := bytes.NewReader([]byte("{\"key\":\"value\"}")) var output bytes.Buffer assert.EqualError(suite.T(), i.GetOutput(context.Background(), input, &output), "cannot output JSON") }) suite.T().Run("Success", func(t *testing.T) { - t.Run("QueryGetAll", func(t *testing.T) { + t.Run("QueryGetAll", func(_ *testing.T) { i := &JSONFlags{JSON: true, JQ: "."} input := bytes.NewReader([]byte("{\"key\":\"value\"}")) var output bytes.Buffer assert.NoError(suite.T(), i.GetOutput(context.Background(), input, &output)) assert.Equal(suite.T(), "{\"key\":\"value\"}\n", output.String()) }) - t.Run("QueryGetValue", func(t *testing.T) { + t.Run("QueryGetValue", func(_ *testing.T) { i := &JSONFlags{JSON: true, JQ: ".key"} input := bytes.NewReader([]byte("{\"key\":\"value\"}")) var output bytes.Buffer diff --git a/pkg/cmd/help/config.go b/pkg/cmd/help/config.go index 178c57a7..01b9e2b6 100644 --- a/pkg/cmd/help/config.go +++ b/pkg/cmd/help/config.go @@ -27,7 +27,7 @@ import ( ) func configHelpTopicFunc() TopicFunc { - return func(c *cobra.Command, args []string) { + return func(c *cobra.Command, _ []string) { b := bytes.NewBufferString("# lstn configuration file\n\n") fmt.Fprintf(b, "%s\n\n", "The `lstn` CLI looks for a configuration file .lstn.yaml in your `$HOME` directory when it starts.") fmt.Fprintf(b, "%s\n", "In this file you can set the values for the global `lstn` configurations.") diff --git a/pkg/cmd/help/environment.go b/pkg/cmd/help/environment.go index 1b11d56e..1506d26c 100644 --- a/pkg/cmd/help/environment.go +++ b/pkg/cmd/help/environment.go @@ -26,7 +26,7 @@ import ( ) func envHelpTopicFunc() TopicFunc { - return func(c *cobra.Command, args []string) { + return func(c *cobra.Command, _ []string) { b := bytes.NewBufferString("# lstn environment variables\n\n") fmt.Fprintf(b, "%s\n\n", "The environment variables override any corresponding configuration setting.") fmt.Fprintf(b, "%s\n\n", "But flags override them.") diff --git a/pkg/cmd/help/manual.go b/pkg/cmd/help/manual.go index e8fa7613..f230bc2f 100644 --- a/pkg/cmd/help/manual.go +++ b/pkg/cmd/help/manual.go @@ -91,7 +91,7 @@ func cReference(w io.Writer, c *cobra.Command, depth int) { } func manualHelpTopicFunc() TopicFunc { - return func(c *cobra.Command, args []string) { + return func(c *cobra.Command, _ []string) { b := bytes.NewBufferString("# lstn cheatsheet\n\n") // NOTE > Assuming c.Parent() is the root one diff --git a/pkg/cmd/help/reporters.go b/pkg/cmd/help/reporters.go index 2e187996..a5796324 100644 --- a/pkg/cmd/help/reporters.go +++ b/pkg/cmd/help/reporters.go @@ -24,7 +24,7 @@ import ( ) func reportersHelpTopicFunc() TopicFunc { - return func(c *cobra.Command, args []string) { + return func(c *cobra.Command, _ []string) { b := bytes.NewBufferString("# lstn reporters\n\n") for _, reportType := range cmd.AllReportTypes { diff --git a/pkg/listen/types_test.go b/pkg/listen/types_test.go index 3bc2ac13..03c2181d 100644 --- a/pkg/listen/types_test.go +++ b/pkg/listen/types_test.go @@ -540,7 +540,7 @@ func (suite *TypesSuite) TestResponseMarshalJSON() { for _, tc := range cases { r := new(Response) - t.Run(tc.desc, func(t *testing.T) { + t.Run(tc.desc, func(_ *testing.T) { dec := json.NewDecoder(tc.reader) suite.NoError(dec.Decode(r)) suite.Equal(*r, tc.expected) diff --git a/pkg/npm/types.go b/pkg/npm/types.go index 4ec0d296..88a008e5 100644 --- a/pkg/npm/types.go +++ b/pkg/npm/types.go @@ -202,8 +202,8 @@ func NewPackageLockJSONFromBytes(b []byte) (PackageLockJSON, error) { return ret, nil } -// GetPackageLockJsonFromDir creates a PackageLockJSON instance from the existing package-lock.json in dir, if any. -func GetPackageLockJsonFromDir(dir string) (PackageLockJSON, error) { +// GetPackageLockJSONFromDir creates a PackageLockJSON instance from the existing package-lock.json in dir, if any. +func GetPackageLockJSONFromDir(dir string) (PackageLockJSON, error) { reader, err := read(dir, "package-lock.json") if err != nil { return nil, err diff --git a/pkg/transform/transform.go b/pkg/transform/transform.go index 3195e5c4..5a232c43 100644 --- a/pkg/transform/transform.go +++ b/pkg/transform/transform.go @@ -33,7 +33,7 @@ func init() { Singleton = modifiers.New() Singleton.SetTagName("transform") - Singleton.Register("unique", func(ctx context.Context, fl mold.FieldLevel) error { + Singleton.Register("unique", func(_ context.Context, fl mold.FieldLevel) error { if fl.Field().Kind() == reflect.Slice { unique := fl.Field().Interface() switch fl.Field().Type().Elem().String() {