Showing 15 of 15 total issues
Function NewPrimaryHandler
has 209 lines of code (exceeds 50 allowed). Consider refactoring. Open
func NewPrimaryHandler(logger *zap.Logger, v *viper.Viper, registry xmetrics.Registry, e service.Environment, tracing candlelight.Tracing) (http.Handler, error) {
var cfg fanout.Configuration
if err := v.UnmarshalKey("fanout", &cfg); err != nil {
return nil, err
}
Function validateWRP
has a Cognitive Complexity of 49 (exceeds 20 allowed). Consider refactoring. Open
func validateWRP(v *viper.Viper, logger *zap.Logger, tf *touchstone.Factory) (func(http.Handler) http.Handler, error) {
var (
errs error
vals []wrpvalidator.MetaValidator
)
- 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
Function authChain
has 138 lines of code (exceeds 50 allowed). Consider refactoring. Open
func authChain(v *viper.Viper, logger *zap.Logger, registry xmetrics.Registry, tf *touchstone.Factory) (alice.Chain, error) {
if registry == nil {
return alice.Chain{}, errors.New("nil registry")
}
Function NewPrimaryHandler
has a Cognitive Complexity of 41 (exceeds 20 allowed). Consider refactoring. Open
func NewPrimaryHandler(logger *zap.Logger, v *viper.Viper, registry xmetrics.Registry, e service.Environment, tracing candlelight.Tracing) (http.Handler, error) {
var cfg fanout.Configuration
if err := v.UnmarshalKey("fanout", &cfg); err != nil {
return nil, err
}
- 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
File primaryHandler.go
has 544 lines of code (exceeds 500 allowed). Consider refactoring. Open
// SPDX-FileCopyrightText: 2019 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
package main
Function validateWRP
has 71 lines of code (exceeds 50 allowed). Consider refactoring. Open
func validateWRP(v *viper.Viper, logger *zap.Logger, tf *touchstone.Factory) (func(http.Handler) http.Handler, error) {
var (
errs error
vals []wrpvalidator.MetaValidator
)
Function scytale
has 66 lines of code (exceeds 50 allowed). Consider refactoring. Open
func scytale(arguments []string) int {
//
// Initialize the server environment: command-line flags, Viper, logging, and the WebPA instance
//
Function authChain
has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring. Open
func authChain(v *viper.Viper, logger *zap.Logger, registry xmetrics.Registry, tf *touchstone.Factory) (alice.Chain, error) {
if registry == nil {
return alice.Chain{}, errors.New("nil registry")
}
- 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 wrpPartnersAccess.authorizeWRP
has 61 lines of code (exceeds 50 allowed). Consider refactoring. Open
func (p *wrpPartnersAccess) authorizeWRP(ctx context.Context, message *wrp.Message) (bool, error) {
var (
auth, ok = bascule.FromContext(ctx)
satClientID = "none"
)
Function NewPrimaryHandler
has 14 return statements (exceeds 4 allowed). Open
func NewPrimaryHandler(logger *zap.Logger, v *viper.Viper, registry xmetrics.Registry, e service.Environment, tracing candlelight.Tracing) (http.Handler, error) {
var cfg fanout.Configuration
if err := v.UnmarshalKey("fanout", &cfg); err != nil {
return nil, err
}
Method wrpPartnersAccess.authorizeWRP
has 14 return statements (exceeds 4 allowed). Open
func (p *wrpPartnersAccess) authorizeWRP(ctx context.Context, message *wrp.Message) (bool, error) {
var (
auth, ok = bascule.FromContext(ctx)
satClientID = "none"
)
Function authChain
has 9 return statements (exceeds 4 allowed). Open
func authChain(v *viper.Viper, logger *zap.Logger, registry xmetrics.Registry, tf *touchstone.Factory) (alice.Chain, error) {
if registry == nil {
return alice.Chain{}, errors.New("nil registry")
}
Function createEndpoints
has 6 return statements (exceeds 4 allowed). Open
func createEndpoints(logger *zap.Logger, cfg fanout.Configuration, registry xmetrics.Registry, e service.Environment) (fanout.Endpoints, error) {
if len(cfg.Endpoints) > 0 {
logger.Info("using configured endpoints for fanout", zap.Any("endpoints", cfg.Endpoints))
return fanout.ParseURLs(cfg.Endpoints...)
} else if e != nil {
Function scytale
has 6 return statements (exceeds 4 allowed). Open
func scytale(arguments []string) int {
//
// Initialize the server environment: command-line flags, Viper, logging, and the WebPA instance
//
Function NewPrimaryHandler
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
func NewPrimaryHandler(logger *zap.Logger, v *viper.Viper, registry xmetrics.Registry, e service.Environment, tracing candlelight.Tracing) (http.Handler, error) {