go-sprout/sprout

View on GitHub

Showing 18 of 48 total issues

Method StringsRegistry.transformString has a Cognitive Complexity of 32 (exceeds 20 allowed). Consider refactoring.
Open

func (sr *StringsRegistry) transformString(style caseStyle, str string) string {
    var result strings.Builder
    result.Grow(len(str) + 10) // Allocate a bit more for potential separators

    capitalizeNext := style.CapitalizeNext
Severity: Minor
Found in registry/strings/helpers.go - About 2 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

Method RandomRegistry.randomString has a Cognitive Complexity of 28 (exceeds 20 allowed). Consider refactoring.
Open

func (rr *RandomRegistry) randomString(count int, opts *randomOpts) string {
    if count <= 0 {
        return ""
    }

Severity: Minor
Found in registry/random/helpers.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 TimeRegistry.DurationRound has 55 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func (tr *TimeRegistry) DurationRound(duration any) string {
    var d time.Duration

    switch duration := duration.(type) {
    case string:
Severity: Minor
Found in registry/time/functions.go - About 1 hr to fix

    Method CryptoRegistry.parsePrivateKeyPEM has 10 return statements (exceeds 4 allowed).
    Open

    func (ch *CryptoRegistry) parsePrivateKeyPEM(pemBlock string) (crypto.PrivateKey, error) {
        block, _ := pem.Decode([]byte(pemBlock))
        if block == nil {
            return nil, errors.New("no PEM data in input")
        }
    Severity: Major
    Found in registry/crypto/helpers.go - About 1 hr to fix

      Method SlicesRegistry.Slice has 8 return statements (exceeds 4 allowed).
      Open

      func (sr *SlicesRegistry) Slice(args ...any) (any, error) {
          // ! BACKWARDS COMPATIBILITY: deprecated in v1.0 and removed in v1.1
          // ! Due to change in signature, this function still supports the old signature
          // ! to let users transition to the new signature.
          // * Old signature: Slice(list any, indices ...any)
      Severity: Major
      Found in registry/slices/functions.go - About 50 mins to fix

        Method StringsRegistry.wordWrap has a Cognitive Complexity of 23 (exceeds 20 allowed). Consider refactoring.
        Open

        func (sr *StringsRegistry) wordWrap(wrapLength int, newLineCharacter string, wrapLongWords bool, str string) string {
            if wrapLength < 1 {
                wrapLength = 1
            }
            if newLineCharacter == "" {
        Severity: Minor
        Found in registry/strings/helpers.go - About 45 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

        Method CryptoRegistry.generateSignedCertificateWithKeyInternal has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            cn string,
            ips []any,
            alternateDNS []any,
            daysValid int,
            ca Certificate,
        Severity: Minor
        Found in registry/crypto/helpers.go - About 45 mins to fix

          Method CryptoRegistry.GenerateSignedCertificateWithPEMKey has 6 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              cn string,
              ips []any,
              alternateDNS []any,
              daysValid int,
              ca Certificate,
          Severity: Minor
          Found in registry/crypto/functions.go - About 45 mins to fix

            Method CryptoRegistry.BuildCustomCertificate has 6 return statements (exceeds 4 allowed).
            Open

            func (ch *CryptoRegistry) BuildCustomCertificate(b64cert string, b64key string) (Certificate, error) {
                crt := Certificate{}
            
                cert, err := base64.StdEncoding.DecodeString(b64cert)
                if err != nil {
            Severity: Major
            Found in registry/crypto/functions.go - About 40 mins to fix

              Method CryptoRegistry.generateSelfSignedCertificateWithKeyInternal has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  cn string,
                  ips []any,
                  alternateDNS []any,
                  daysValid int,
                  priv crypto.PrivateKey,
              Severity: Minor
              Found in registry/crypto/helpers.go - About 35 mins to fix

                Method CryptoRegistry.GenerateSignedCertificate has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    cn string,
                    ips []any,
                    alternateDNS []any,
                    daysValid int,
                    ca Certificate,
                Severity: Minor
                Found in registry/crypto/functions.go - About 35 mins to fix

                  Method CryptoRegistry.GenerateSelfSignedCertificateWithPEMKey has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      cn string,
                      ips []any,
                      alternateDNS []any,
                      daysValid int,
                      privPEM string,
                  Severity: Minor
                  Found in registry/crypto/functions.go - About 35 mins to fix

                    Function StrSlice has 5 return statements (exceeds 4 allowed).
                    Open

                    func StrSlice(value any) []string {
                        if value == nil {
                            return []string{}
                        }
                    
                    
                    Severity: Major
                    Found in internal/helpers/helpers.go - About 35 mins to fix

                      Method CryptoRegistry.generateSignedCertificateWithKeyInternal has 5 return statements (exceeds 4 allowed).
                      Open

                      func (ch *CryptoRegistry) generateSignedCertificateWithKeyInternal(
                          cn string,
                          ips []any,
                          alternateDNS []any,
                          daysValid int,
                      Severity: Major
                      Found in registry/crypto/helpers.go - About 35 mins to fix

                        Method MapsRegistry.Omit has 5 return statements (exceeds 4 allowed).
                        Open

                        func (mr *MapsRegistry) Omit(args ...any) (map[string]any, error) {
                            // ! BACKWARDS COMPATIBILITY: deprecated in v1.0 and removed in v1.1
                            // ! Due to change in signature, this function still supports the old signature
                            // ! to let users transition to the new signature.
                            // * Old signature: Omit(map[string]any, ...string)
                        Severity: Major
                        Found in registry/maps/functions.go - About 35 mins to fix

                          Method MapsRegistry.Pick has 5 return statements (exceeds 4 allowed).
                          Open

                          func (mr *MapsRegistry) Pick(args ...any) (map[string]any, error) {
                              // ! BACKWARDS COMPATIBILITY: deprecated in v1.0 and removed in v1.1
                              // ! Due to change in signature, this function still supports the old signature
                              // ! to let users transition to the new signature.
                              // * Old signature: Pick(map[string]any, ...string)
                          Severity: Major
                          Found in registry/maps/functions.go - About 35 mins to fix

                            Method SlicesRegistry.Append has 5 return statements (exceeds 4 allowed).
                            Open

                            func (sr *SlicesRegistry) Append(args ...any) ([]any, error) {
                                // ! BACKWARDS COMPATIBILITY: deprecated in v1.0 and removed in v1.1
                                // ! Due to change in signature, this function still supports the old signature
                                // ! to let users transition to the new signature.
                                // * Old signature: Append(list any, v any)
                            Severity: Major
                            Found in registry/slices/functions.go - About 35 mins to fix

                              Method CryptoRegistry.getCertAndKey has 5 return statements (exceeds 4 allowed).
                              Open

                              func (ch *CryptoRegistry) getCertAndKey(
                                  template *x509.Certificate,
                                  signeeKey crypto.PrivateKey,
                                  parent *x509.Certificate,
                                  signingKey crypto.PrivateKey,
                              Severity: Major
                              Found in registry/crypto/helpers.go - About 35 mins to fix
                                Severity
                                Category
                                Status
                                Source
                                Language