From 01a38884ebbdcc36a2ea42b01a6c153682a75391 Mon Sep 17 00:00:00 2001 From: Charlie Egan Date: Thu, 18 Apr 2024 09:03:32 +0100 Subject: [PATCH] fixes: rename Key to Name This is to make it more consistent with rule names Signed-off-by: Charlie Egan --- pkg/fixer/fixer.go | 2 +- pkg/fixer/fixes/fixes.go | 6 +++--- pkg/fixer/fixes/fmt.go | 16 ++++++++-------- pkg/fixer/fixes/nowhitespacecomment.go | 2 +- pkg/fixer/fixes/useassignmentoperator.go | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/pkg/fixer/fixer.go b/pkg/fixer/fixer.go index 2018fd42c..c293d7291 100644 --- a/pkg/fixer/fixer.go +++ b/pkg/fixer/fixer.go @@ -25,7 +25,7 @@ func (f *Fixer) RegisterFixes(fixes ...fixes.Fix) { } for _, fix := range fixes { - f.registeredFixes[fix.Key()] = fix + f.registeredFixes[fix.Name()] = fix } } diff --git a/pkg/fixer/fixes/fixes.go b/pkg/fixer/fixes/fixes.go index a20c6aedd..9fd77ae66 100644 --- a/pkg/fixer/fixes/fixes.go +++ b/pkg/fixer/fixes/fixes.go @@ -11,7 +11,7 @@ func NewDefaultFixes() []Fix { return []Fix{ &Fmt{}, &Fmt{ - KeyOverride: "use-rego-v1", + NameOverride: "use-rego-v1", OPAFmtOpts: format.Opts{ RegoVersion: ast.RegoV0CompatV1, }, @@ -23,9 +23,9 @@ func NewDefaultFixes() []Fix { // Fix is the interface that must be implemented by all fixes. type Fix interface { - // Key returns the unique key for the fix, this should correlate with the + // Name returns the unique key for the fix, this should correlate with the // violation that the fix is meant to address. - Key() string + Name() string Fix(fc *FixCandidate, opts *RuntimeOptions) ([]FixResult, error) } diff --git a/pkg/fixer/fixes/fmt.go b/pkg/fixer/fixes/fmt.go index 8d291ba4c..26c3d1f25 100644 --- a/pkg/fixer/fixes/fmt.go +++ b/pkg/fixer/fixes/fmt.go @@ -9,19 +9,19 @@ import ( ) type Fmt struct { - // KeyOverride allows this fix config to also be registered under another key, see note - // in Key(). - KeyOverride string + // NameOverride allows this fix config to also be registered under another name, see note + // in Name(). + NameOverride string // OPAFmtOpts are the options to pass to OPA's format.SourceWithOpts // function. OPAFmtOpts format.Opts } -func (f *Fmt) Key() string { - // this allows this fix config to also be registered under another key so that different - // configurations can be registered under other linter rule keys. - if f.KeyOverride != "" { - return f.KeyOverride +func (f *Fmt) Name() string { + // this allows this fix config to also be registered under another name so that different + // configurations can be registered under other linter rule names. + if f.NameOverride != "" { + return f.NameOverride } return "opa-fmt" diff --git a/pkg/fixer/fixes/nowhitespacecomment.go b/pkg/fixer/fixes/nowhitespacecomment.go index e2a58feb4..56211ce4a 100644 --- a/pkg/fixer/fixes/nowhitespacecomment.go +++ b/pkg/fixer/fixes/nowhitespacecomment.go @@ -7,7 +7,7 @@ import ( type NoWhitespaceComment struct{} -func (*NoWhitespaceComment) Key() string { +func (*NoWhitespaceComment) Name() string { return "no-whitespace-comment" } diff --git a/pkg/fixer/fixes/useassignmentoperator.go b/pkg/fixer/fixes/useassignmentoperator.go index 84120a4ff..0bc0afac0 100644 --- a/pkg/fixer/fixes/useassignmentoperator.go +++ b/pkg/fixer/fixes/useassignmentoperator.go @@ -7,7 +7,7 @@ import ( type UseAssignmentOperator struct{} -func (*UseAssignmentOperator) Key() string { +func (*UseAssignmentOperator) Name() string { return "use-assignment-operator" }