Skip to content

Commit ce1a0f7

Browse files
authored
chore: enable all staticcheck linter checks (#405)
Signed-off-by: Sahid Velji <[email protected]>
1 parent 137156b commit ce1a0f7

13 files changed

Lines changed: 31 additions & 16 deletions

File tree

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ linters:
1616
- unused
1717
- misspell
1818
- dupword
19+
settings:
20+
staticcheck:
21+
checks:
22+
- "all"
1923

2024
issues:
2125
max-issues-per-linter: 0

openfeature/client.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ func (c *Client) evaluate(
700700

701701
evalCtx = mergeContexts(evalCtx, c.evaluationContext, TransactionContext(ctx), globalEvalCtx) // API (global) -> transaction -> client -> invocation
702702
apiClientInvocationProviderHooks := slices.Concat(globalHooks, c.hooks, options.hooks, provider.Hooks()) // API, Client, Invocation, Provider
703-
providerInvocationClientApiHooks := slices.Concat(provider.Hooks(), options.hooks, c.hooks, globalHooks) // Provider, Invocation, Client, API
703+
providerInvocationClientAPIHooks := slices.Concat(provider.Hooks(), options.hooks, c.hooks, globalHooks) // Provider, Invocation, Client, API
704704

705705
var err error
706706
hookCtx := HookContext{
@@ -713,20 +713,20 @@ func (c *Client) evaluate(
713713
}
714714

715715
defer func() {
716-
c.finallyHooks(ctx, hookCtx, providerInvocationClientApiHooks, evalDetails, options)
716+
c.finallyHooks(ctx, hookCtx, providerInvocationClientAPIHooks, evalDetails, options)
717717
}()
718718

719719
// bypass short-circuit logic for the Noop provider; it is essentially stateless and a "special case"
720720
if _, ok := provider.(NoopProvider); !ok {
721721
// short circuit if provider is in NOT READY state
722722
if c.State() == NotReadyState {
723-
c.errorHooks(ctx, hookCtx, providerInvocationClientApiHooks, ProviderNotReadyError, options)
723+
c.errorHooks(ctx, hookCtx, providerInvocationClientAPIHooks, ProviderNotReadyError, options)
724724
return evalDetails, ProviderNotReadyError
725725
}
726726

727727
// short circuit if provider is in FATAL state
728728
if c.State() == FatalState {
729-
c.errorHooks(ctx, hookCtx, providerInvocationClientApiHooks, ProviderFatalError, options)
729+
c.errorHooks(ctx, hookCtx, providerInvocationClientAPIHooks, ProviderFatalError, options)
730730
return evalDetails, ProviderFatalError
731731
}
732732
}
@@ -735,7 +735,7 @@ func (c *Client) evaluate(
735735
hookCtx.evaluationContext = evalCtx
736736
if err != nil {
737737
err = fmt.Errorf("before hook: %w", err)
738-
c.errorHooks(ctx, hookCtx, providerInvocationClientApiHooks, err, options)
738+
c.errorHooks(ctx, hookCtx, providerInvocationClientAPIHooks, err, options)
739739
return evalDetails, err
740740
}
741741

@@ -769,17 +769,17 @@ func (c *Client) evaluate(
769769
err = resolution.Error()
770770
if err != nil {
771771
err = fmt.Errorf("error code: %w", err)
772-
c.errorHooks(ctx, hookCtx, providerInvocationClientApiHooks, err, options)
772+
c.errorHooks(ctx, hookCtx, providerInvocationClientAPIHooks, err, options)
773773
evalDetails.ResolutionDetail = resolution.ResolutionDetail()
774774
evalDetails.Reason = ErrorReason
775775
return evalDetails, err
776776
}
777777
evalDetails.Value = resolution.Value
778778
evalDetails.ResolutionDetail = resolution.ResolutionDetail()
779779

780-
if err := c.afterHooks(ctx, hookCtx, providerInvocationClientApiHooks, evalDetails, options); err != nil {
780+
if err := c.afterHooks(ctx, hookCtx, providerInvocationClientAPIHooks, evalDetails, options); err != nil {
781781
err = fmt.Errorf("after hook: %w", err)
782-
c.errorHooks(ctx, hookCtx, providerInvocationClientApiHooks, err, options)
782+
c.errorHooks(ctx, hookCtx, providerInvocationClientAPIHooks, err, options)
783783
return evalDetails, err
784784
}
785785

openfeature/client_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ type clientMocks struct {
1919

2020
func hydratedMocksForClientTests(t *testing.T, expectedEvaluations int) clientMocks {
2121
ctrl := gomock.NewController(t)
22-
mockClientApi := NewMockclientEvent(ctrl)
23-
mockEvaluationApi := NewMockevaluationImpl(ctrl)
22+
mockClientAPI := NewMockclientEvent(ctrl)
23+
mockEvaluationAPI := NewMockevaluationImpl(ctrl)
2424
mockProvider := NewMockFeatureProvider(ctrl)
2525

26-
mockClientApi.EXPECT().State(gomock.Any()).AnyTimes().Return(ReadyState)
26+
mockClientAPI.EXPECT().State(gomock.Any()).AnyTimes().Return(ReadyState)
2727

2828
mockProvider.EXPECT().Metadata().AnyTimes()
2929
mockProvider.EXPECT().Hooks().AnyTimes()
30-
mockEvaluationApi.EXPECT().ForEvaluation(gomock.Any()).Times(expectedEvaluations).DoAndReturn(func(_ string) (*MockFeatureProvider, []Hook, EvaluationContext) {
30+
mockEvaluationAPI.EXPECT().ForEvaluation(gomock.Any()).Times(expectedEvaluations).DoAndReturn(func(_ string) (*MockFeatureProvider, []Hook, EvaluationContext) {
3131
return mockProvider, nil, EvaluationContext{}
3232
})
3333

3434
return clientMocks{
35-
clientHandlerAPI: mockClientApi,
36-
evaluationAPI: mockEvaluationApi,
35+
clientHandlerAPI: mockClientAPI,
36+
evaluationAPI: mockEvaluationAPI,
3737
providerAPI: mockProvider,
3838
}
3939
}

openfeature/evaluation_context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func NewTargetlessEvaluationContext(attributes map[string]any) EvaluationContext
6060
return NewEvaluationContext("", attributes)
6161
}
6262

63-
// NewTransactionContext constructs a TransactionContext
63+
// WithTransactionContext constructs a TransactionContext.
6464
//
6565
// ctx - the context to embed the EvaluationContext in
6666
// ec - the EvaluationContext to embed into the context

openfeature/hooks/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package hooks provides OpenFeature hooks.
2+
package hooks

openfeature/internal/context_key.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package internal contains internal identifiers for the OpenFeature SDK.
12
package internal
23

34
// ContextKey is just an empty struct. It exists so TransactionContext can be

openfeature/memprovider/in_memory_provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package memprovider provides an in-memory feature flag provider for OpenFeature.
12
package memprovider
23

34
import (

openfeature/openfeature.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ func initSingleton() {
2222

2323
// GetApiInstance returns the current singleton IEvaluation instance.
2424
// This is the preferred interface to interact with OpenFeature functionalities
25+
//
26+
//nolint:staticcheck // Renaming this now would be a breaking change.
2527
func GetApiInstance() IEvaluation {
2628
return api
2729
}

openfeature/testing/testprovider.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package testing provides a test-aware feature flag provider for OpenFeature.
12
package testing
23

34
import (
@@ -27,9 +28,9 @@ type TestProvider struct {
2728
providers *sync.Map
2829
}
2930

30-
// UsingFlags sets flags for the scope of a test
3131
type TestFramework = interface{ Name() string }
3232

33+
// UsingFlags sets flags for the scope of a test.
3334
func (tp TestProvider) UsingFlags(test TestFramework, flags map[string]memprovider.InMemoryFlag) {
3435
storeGoroutineLocal(test.Name())
3536
tp.providers.Store(test.Name(), memprovider.NewInMemoryProvider(flags))

pkg/openfeature/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//nolint:staticcheck
12
package openfeature
23

34
import (

0 commit comments

Comments
 (0)