xmidt-org/scytale

View on GitHub

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
    }
Severity: Major
Found in primaryHandler.go - About 7 hrs to fix

    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
        )
    Severity: Minor
    Found in primaryHandler.go - About 5 hrs to fix

    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")
        }
    
    
    Severity: Major
    Found in primaryHandler.go - About 4 hrs to fix

      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
          }
      Severity: Minor
      Found in primaryHandler.go - About 3 hrs to fix

      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
      
      
      Severity: Minor
      Found in primaryHandler.go - About 3 hrs to fix

        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
            )
        Severity: Minor
        Found in primaryHandler.go - About 1 hr to fix

          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
              //
          
          
          Severity: Minor
          Found in main.go - About 1 hr to fix

            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")
                }
            
            
            Severity: Minor
            Found in primaryHandler.go - About 1 hr to fix

            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"
                )
            Severity: Minor
            Found in WRPAccessControl.go - About 1 hr to fix

              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
                  }
              Severity: Major
              Found in primaryHandler.go - About 1 hr to fix

                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"
                    )
                Severity: Major
                Found in WRPAccessControl.go - About 1 hr to fix

                  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")
                      }
                  
                  
                  Severity: Major
                  Found in primaryHandler.go - About 55 mins to fix

                    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 {
                    Severity: Major
                    Found in primaryHandler.go - About 40 mins to fix

                      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
                          //
                      
                      
                      Severity: Major
                      Found in main.go - About 40 mins to fix

                        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) {
                        Severity: Minor
                        Found in primaryHandler.go - About 35 mins to fix
                          Severity
                          Category
                          Status
                          Source
                          Language