From ef6902957c74ec6b67039e7d9bc55381f064272d Mon Sep 17 00:00:00 2001 From: Matt Toohey Date: Tue, 8 Oct 2024 09:24:28 +1100 Subject: [PATCH] fix lint --- backend/controller/admin/local_client.go | 2 +- frontend/cli/cmd_schema_diff.go | 2 +- go-runtime/compile/build.go | 6 +++++- internal/buildengine/languageplugin/go_plugin_helpers.go | 4 ++-- internal/buildengine/languageplugin/go_plugin_test.go | 1 + internal/buildengine/languageplugin/java_plugin_test.go | 1 + internal/moduleconfig/moduleconfig.go | 2 +- internal/moduleconfig/moduleconfig_test.go | 1 + 8 files changed, 13 insertions(+), 6 deletions(-) diff --git a/backend/controller/admin/local_client.go b/backend/controller/admin/local_client.go index 61f59c6848..eccd6d0887 100644 --- a/backend/controller/admin/local_client.go +++ b/backend/controller/admin/local_client.go @@ -57,7 +57,7 @@ func (s *diskSchemaRetriever) GetActiveSchema(ctx context.Context) (*schema.Sche if err != nil { moduleSchemas <- either.RightOf[*schema.Module](fmt.Errorf("could not load plugin for %s: %w", m.Module, err)) } - defer plugin.Kill(ctx) + defer plugin.Kill(ctx) // nolint:errcheck customDefaults, err := plugin.ModuleConfigDefaults(ctx, m.Dir) if err != nil { diff --git a/frontend/cli/cmd_schema_diff.go b/frontend/cli/cmd_schema_diff.go index 64788ce327..051f4d55a9 100644 --- a/frontend/cli/cmd_schema_diff.go +++ b/frontend/cli/cmd_schema_diff.go @@ -106,7 +106,7 @@ func localSchema(ctx context.Context, projectConfig projectconfig.Config) (*sche if err != nil { moduleSchemas <- either.RightOf[*schema.Module](m) } - defer plugin.Kill(ctx) + defer plugin.Kill(ctx) // nolint:errcheck customDefaults, err := plugin.ModuleConfigDefaults(ctx, m.Dir) if err != nil { diff --git a/go-runtime/compile/build.go b/go-runtime/compile/build.go index 7bb57bb81e..660f2e384e 100644 --- a/go-runtime/compile/build.go +++ b/go-runtime/compile/build.go @@ -1188,7 +1188,11 @@ func writeSchemaErrors(config moduleconfig.AbsModuleConfig, errors []builderrors if err != nil { return fmt.Errorf("failed to marshal errors: %w", err) } - return os.WriteFile(config.Errors, elBytes, 0600) + err = os.WriteFile(config.Errors, elBytes, 0600) + if err != nil { + return fmt.Errorf("could not write build errors: %w", err) + } + return nil } // returns the import path and directory name for a Go type diff --git a/internal/buildengine/languageplugin/go_plugin_helpers.go b/internal/buildengine/languageplugin/go_plugin_helpers.go index 59cf77e74d..02bcdddd5a 100644 --- a/internal/buildengine/languageplugin/go_plugin_helpers.go +++ b/internal/buildengine/languageplugin/go_plugin_helpers.go @@ -33,7 +33,7 @@ func replacementWatches(moduleDir, deployDir string) ([]string, error) { if strings.HasPrefix(r.New.Path, ".") { relPath, err := filepath.Rel(filepath.Dir(goModPath), filepath.Join(filepath.Dir(goModPath), r.New.Path)) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to get relative path for %s: %w", r.New.Path, err) } replacements[r.Old.Path] = relPath } @@ -111,7 +111,7 @@ func parseImports(filePath string) ([]string, error) { fset := token.NewFileSet() file, err := parser.ParseFile(fset, filePath, nil, parser.ImportsOnly) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to parse imports in %s: %w", filePath, err) } var imports []string diff --git a/internal/buildengine/languageplugin/go_plugin_test.go b/internal/buildengine/languageplugin/go_plugin_test.go index 890bc4f303..56091e56fa 100644 --- a/internal/buildengine/languageplugin/go_plugin_test.go +++ b/internal/buildengine/languageplugin/go_plugin_test.go @@ -47,6 +47,7 @@ func TestExtractModuleDepsGo(t *testing.T) { } func TestGoConfigDefaults(t *testing.T) { + t.Parallel() for _, tt := range []struct { dir string expected moduleconfig.CustomDefaults diff --git a/internal/buildengine/languageplugin/java_plugin_test.go b/internal/buildengine/languageplugin/java_plugin_test.go index 022e575e30..b156cd2af4 100644 --- a/internal/buildengine/languageplugin/java_plugin_test.go +++ b/internal/buildengine/languageplugin/java_plugin_test.go @@ -16,6 +16,7 @@ func TestExtractModuleDepsKotlin(t *testing.T) { } func TestJavaConfigDefaults(t *testing.T) { + t.Parallel() watch := []string{ "pom.xml", "src/**", diff --git a/internal/moduleconfig/moduleconfig.go b/internal/moduleconfig/moduleconfig.go index 44041fa3fe..65be0ad80e 100644 --- a/internal/moduleconfig/moduleconfig.go +++ b/internal/moduleconfig/moduleconfig.go @@ -146,7 +146,7 @@ func (c ModuleConfig) Abs() AbsModuleConfig { return AbsModuleConfig(clone) } -// configureDefaults defaults sets values for empty fields and validates the config. +// FillDefaultsAndValidate sets values for empty fields and validates the config. // It involves standard defaults for Real and Errors fields, and also looks at CustomDefaults for // defaulting other fields. func (c UnvalidatedModuleConfig) FillDefaultsAndValidate(customDefaults CustomDefaults) (ModuleConfig, error) { diff --git a/internal/moduleconfig/moduleconfig_test.go b/internal/moduleconfig/moduleconfig_test.go index ea79657fa5..44da74ee44 100644 --- a/internal/moduleconfig/moduleconfig_test.go +++ b/internal/moduleconfig/moduleconfig_test.go @@ -7,6 +7,7 @@ import ( ) func TestDefaulting(t *testing.T) { + t.Parallel() for _, tt := range []struct { config UnvalidatedModuleConfig defaults CustomDefaults