Showing 13 of 138 total issues
Function NewClient
has 105 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func NewClient(options ...ConfigOption) (*Client, error) {
errChannels := errorChannels{
errors: make(chan error, 3),
warnings: make(chan error, 3),
Method Client.isEnabled
has 73 lines of code (exceeds 50 allowed). Consider refactoring. Open
Open
func (uc *Client) isEnabled(feature string, options ...FeatureOption) api.StrategyResult {
var opts featureOption
for _, o := range options {
o(&opts)
}
Method Client.isEnabled
has a Cognitive Complexity of 27 (exceeds 20 allowed). Consider refactoring. Open
Open
func (uc *Client) isEnabled(feature string, options ...FeatureOption) api.StrategyResult {
var opts featureOption
for _, o := range options {
o(&opts)
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method Client.isEnabled
has 9 return statements (exceeds 4 allowed). Open
Open
func (uc *Client) isEnabled(feature string, options ...FeatureOption) api.StrategyResult {
var opts featureOption
for _, o := range options {
o(&opts)
}
Method Client.isParentDependencySatisfied
has 8 return statements (exceeds 4 allowed). Open
Open
func (uc *Client) isParentDependencySatisfied(feature *api.Feature, context context.Context) bool {
warnOnce := &WarnOnce{}
dependenciesSatisfied := func(parent api.Dependency) bool {
parentToggle := uc.repository.getToggle(parent.Feature)
Method Client.getVariantWithoutMetrics
has 8 return statements (exceeds 4 allowed). Open
Open
func (uc *Client) getVariantWithoutMetrics(feature string, options ...VariantOption) *api.Variant {
defaultVariant := api.GetDefaultVariant()
var opts variantOption
for _, o := range options {
o(&opts)
Avoid deeply nested control flow statements. Open
Open
} else if s, isString := param.(string); isString {
f, err := strconv.ParseFloat(s, 64)
if err == nil {
result, ok = f, true
}
Method repository.fetch
has 6 return statements (exceeds 4 allowed). Open
Open
func (r *repository) fetch() error {
u, _ := r.options.url.Parse(getFetchURLPath(r.options.projectName))
req, err := http.NewRequest("GET", u.String(), nil)
if err != nil {
Method remoteAddressStrategy.IsEnabled
has 6 return statements (exceeds 4 allowed). Open
Open
func (s remoteAddressStrategy) IsEnabled(params map[string]interface{}, ctx *context.Context) bool {
value, found := params[strategy.ParamIps]
if !found {
return false
}
Function getSeed
has 6 return statements (exceeds 4 allowed). Open
Open
func getSeed(ctx *context.Context, stickiness string) string {
if stickiness != "default" && stickiness != "" {
value := ctx.Field(stickiness)
if value == "" {
return strconv.Itoa(rand.Intn(10000))
Method gradualRolloutSessionId.IsEnabled
has 5 return statements (exceeds 4 allowed). Open
Open
func (s gradualRolloutSessionId) IsEnabled(params map[string]interface{}, ctx *context.Context) bool {
if ctx == nil || ctx.SessionId == "" {
return false
}
Method gradualRolloutUserId.IsEnabled
has 5 return statements (exceeds 4 allowed). Open
Open
func (s gradualRolloutUserId) IsEnabled(params map[string]interface{}, ctx *context.Context) bool {
if ctx == nil || ctx.UserId == "" {
return false
}
Method Client.sync
has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring. Open
Open
func (uc *Client) sync() {
for {
select {
case e := <-uc.errors:
if uc.errorListener != nil {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"