xmidt-org/themis

View on GitHub

Showing 9 of 39 total issues

Function NewPair has 82 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func NewPair(kid string, key interface{}) (Pair, error) {
    switch k := key.(type) {
    case *rsa.PrivateKey:
        verifyPEM, err := MarshalPKIXPublicKeyToPEM(&k.PublicKey)
        if err != nil {
Severity: Major
Found in key/pair.go - About 2 hrs to fix

    Function NewPair has 15 return statements (exceeds 4 allowed).
    Open

    func NewPair(kid string, key interface{}) (Pair, error) {
        switch k := key.(type) {
        case *rsa.PrivateKey:
            verifyPEM, err := MarshalPKIXPublicKeyToPEM(&k.PublicKey)
            if err != nil {
    Severity: Major
    Found in key/pair.go - About 1 hr to fix

      Function NewRequestBuilders has 55 lines of code (exceeds 50 allowed). Consider refactoring.
      Open

      func NewRequestBuilders(o Options) (RequestBuilders, error) {
          var rb RequestBuilders
          for name, value := range o.Claims {
              if len(value.Header) > 0 || len(value.Parameter) > 0 {
                  if len(value.Variable) > 0 {
      Severity: Minor
      Found in token/transport.go - About 1 hr to fix

        Function main has 53 lines of code (exceeds 50 allowed). Consider refactoring.
        Open

        func main() {
            app := fx.New(
                xlog.Logger(),
                config.CommandLine{Name: applicationName}.Provide(setupFlagSet),
                provideMetrics(),
        Severity: Minor
        Found in main.go - About 1 hr to fix

          Function NewTlsConfig has 6 return statements (exceeds 4 allowed).
          Open

          func NewTlsConfig(t *Tls, extra ...PeerVerifier) (*tls.Config, error) {
              if t == nil {
                  return nil, nil
              }
          
          
          Severity: Major
          Found in xhttp/xhttpserver/tls.go - About 40 mins to fix

            Function CheckServerRequirements has 6 return statements (exceeds 4 allowed).
            Open

            func CheckServerRequirements(k KeyRoutesIn, i IssuerRoutesIn, c ClaimsRoutesIn) error {
                if k.Router != nil && i.Router != nil {
                    // all good ... no need to check anything else
                    return nil
                }
            Severity: Major
            Found in routes.go - About 40 mins to fix

              Method Unmarshal.Provide has 5 return statements (exceeds 4 allowed).
              Open

              func (u Unmarshal) Provide(in ServerIn) (*mux.Router, error) {
                  if !in.Unmarshaller.IsSet(u.Key) {
                      if !u.Optional {
                          return nil, ServerNotConfiguredError{Key: u.Key}
                      }
              Severity: Major
              Found in xhttp/xhttpserver/unmarshal.go - About 35 mins to fix

                Function NewClaimBuilders has a Cognitive Complexity of 22 (exceeds 20 allowed). Consider refactoring.
                Open

                func NewClaimBuilders(n random.Noncer, client xhttpclient.Interface, o Options) (ClaimBuilders, error) {
                    var (
                        // at a minimum, the claims from the request will be copied
                        builders           = ClaimBuilders{requestClaimBuilder{}}
                        staticClaimBuilder = make(staticClaimBuilder)
                Severity: Minor
                Found in token/claimBuilder.go - About 35 mins 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 NewPair has a Cognitive Complexity of 21 (exceeds 20 allowed). Consider refactoring.
                Open

                func NewPair(kid string, key interface{}) (Pair, error) {
                    switch k := key.(type) {
                    case *rsa.PrivateKey:
                        verifyPEM, err := MarshalPKIXPublicKeyToPEM(&k.PublicKey)
                        if err != nil {
                Severity: Minor
                Found in key/pair.go - About 25 mins 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

                Severity
                Category
                Status
                Source
                Language