From 26fe76a04e64c4c55b25965f9f123d7a1ed6e294 Mon Sep 17 00:00:00 2001 From: dobarx Date: Mon, 12 Feb 2024 17:51:58 +0200 Subject: [PATCH] golangci-lint: fix remaining linter issues --- internal/openai/plugin.go | 4 +--- parser/definitions/title.go | 4 +--- parser/evaluator.go | 11 +++++------ parser/parseSectionBlock.go | 1 + pkg/cirularRefDetector/circularRefs.go | 2 +- pkg/diagnostics/diagnostics.go | 2 +- pkg/jsontools/jsontools.go | 2 +- pkg/parexec/limiter.go | 2 +- 8 files changed, 12 insertions(+), 16 deletions(-) diff --git a/internal/openai/plugin.go b/internal/openai/plugin.go index de2849ea..3427897a 100644 --- a/internal/openai/plugin.go +++ b/internal/openai/plugin.go @@ -16,9 +16,7 @@ const ( type ClientLoadFn func(opts ...client.Option) client.Client -var DefaultClientLoader ClientLoadFn = func(opts ...client.Option) client.Client { - return client.New(opts...) -} +var DefaultClientLoader ClientLoadFn = client.New func Plugin(version string, loader ClientLoadFn) *plugin.Schema { if loader == nil { diff --git a/parser/definitions/title.go b/parser/definitions/title.go index 2fd6bf72..550081cb 100644 --- a/parser/definitions/title.go +++ b/parser/definitions/title.go @@ -29,9 +29,7 @@ func (t *TitleInvocation) GetBody() *hclsyntax.Body { } // SetBody implements evaluation.Invocation. -func (*TitleInvocation) SetBody(*hclsyntax.Body) { - return -} +func (*TitleInvocation) SetBody(*hclsyntax.Body) {} var _ evaluation.Invocation = (*TitleInvocation)(nil) diff --git a/parser/evaluator.go b/parser/evaluator.go index aa9aba9a..6f061240 100644 --- a/parser/evaluator.go +++ b/parser/evaluator.go @@ -104,11 +104,11 @@ func (e *Evaluator) EvaluateDocument(d *definitions.Document) (results []string, results = make([]string, 0, len(e.contentCalls)) for _, call := range e.contentCalls { - context, diag := e.evaluateQuery(call) - if diags.Extend(diag) { - // query failed, but context is always valid - // TODO: #28 #29 - } + context, _ := e.evaluateQuery(call) + // if diags.Extend(diag) { + // query failed, but context is always valid + // TODO: #28 #29 + // } result, diag := e.caller.CallContent(call.PluginName, call.Config, call.Invocation, context) if diags.Extend(diag) { // XXX: What to do if we have errors while executing content blocks? @@ -249,5 +249,4 @@ func (e *Evaluator) evaluateSection(s *definitions.ParsedSection) { panic("must be exhaustive") } } - return } diff --git a/parser/parseSectionBlock.go b/parser/parseSectionBlock.go index 35332793..0ceded77 100644 --- a/parser/parseSectionBlock.go +++ b/parser/parseSectionBlock.go @@ -126,6 +126,7 @@ func (db *DefinedBlocks) parseSection(section *definitions.Section) (parsed *def continue } circularRefDetector.Add(section, block.DefRange().Ptr()) + //nolint:gocritic defer circularRefDetector.Remove(section, &diags) parsedSubSection, diag := db.ParseSection(subSection) if diags.Extend(diag) { diff --git a/pkg/cirularRefDetector/circularRefs.go b/pkg/cirularRefDetector/circularRefs.go index 77f7d7f2..2d54845c 100644 --- a/pkg/cirularRefDetector/circularRefs.go +++ b/pkg/cirularRefDetector/circularRefs.go @@ -75,6 +75,6 @@ func (d *circularRefDetector) remove(ptr unsafe.Pointer, diags *diagnostics.Diag diag.Detail, rng.Filename, rng.Start.Line, rng.Start.Column, ) } else { - diag.Detail = diag.Detail + "\n at " + diag.Detail += "\n at " } } diff --git a/pkg/diagnostics/diagnostics.go b/pkg/diagnostics/diagnostics.go index ac0b60b2..a627230a 100644 --- a/pkg/diagnostics/diagnostics.go +++ b/pkg/diagnostics/diagnostics.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/hcl/v2" ) -type Diag hcl.Diagnostics //nolint:errname // Diagnostics does implement error interface, but not, itself, an error. +type Diag hcl.Diagnostics // Diagnostics does implement error interface, but not, itself, an error. type repeatedError struct{} diff --git a/pkg/jsontools/jsontools.go b/pkg/jsontools/jsontools.go index eac0687a..4b3e5415 100644 --- a/pkg/jsontools/jsontools.go +++ b/pkg/jsontools/jsontools.go @@ -70,5 +70,5 @@ func UnmarshalBytes(bytes, value any) error { if !ok { return ErrUnmarshalBytes } - return json.Unmarshal(data, value) //nolint: wrapcheck + return json.Unmarshal(data, value) } diff --git a/pkg/parexec/limiter.go b/pkg/parexec/limiter.go index 3cc88971..38b7dfb5 100644 --- a/pkg/parexec/limiter.go +++ b/pkg/parexec/limiter.go @@ -9,7 +9,7 @@ import ( var NoLimit = (*Limiter)(nil) // DiskIOLimiter is a shared limiter for all Disk IO tasks. -var DiskIOLimiter = NewLimiter(4) //nolint: gomnd +var DiskIOLimiter = NewLimiter(4) // CPULimiter is a shared limiter for all CPU-bound tasks. var CPULimiter = NewLimiter(2 * runtime.NumCPU())