go-sprout/sprout

View on GitHub

Showing 42 of 48 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    switch date := date.(type) {
    default:
        t = time.Now()
    case time.Time:
        t = date
Severity: Minor
Found in registry/time/functions.go and 1 other location - About 45 mins to fix
registry/time/functions.go on lines 119..132

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 117.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (rr *RegexpRegistry) RegexSplit(regex string, str string, n int) ([]string, error) {
          r, err := regexp.Compile(regex)
          if err != nil {
              return []string{}, err
          }
      Severity: Minor
      Found in registry/regexp/functions.go and 1 other location - About 40 mins to fix
      registry/regexp/functions.go on lines 65..71

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 112.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      func (rr *RegexpRegistry) RegexFindAll(regex string, str string, n int) ([]string, error) {
          r, err := regexp.Compile(regex)
          if err != nil {
              return []string{}, err
          }
      Severity: Minor
      Found in registry/regexp/functions.go and 1 other location - About 40 mins to fix
      registry/regexp/functions.go on lines 109..115

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 112.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      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

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              func (rr *RegexpRegistry) RegexReplaceAllLiteral(regex string, s string, replacedBy string) (string, error) {
                  r, err := regexp.Compile(regex)
                  if err != nil {
                      return "", err
                  }
              Severity: Minor
              Found in registry/regexp/functions.go and 1 other location - About 35 mins to fix
              registry/regexp/functions.go on lines 134..140

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 106.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

              func (rr *RegexpRegistry) RegexReplaceAll(regex string, str string, replacedBy string) (string, error) {
                  r, err := regexp.Compile(regex)
                  if err != nil {
                      return "", err
                  }
              Severity: Minor
              Found in registry/regexp/functions.go and 1 other location - About 35 mins to fix
              registry/regexp/functions.go on lines 159..165

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 106.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              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

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                          func (er *EncodingRegistry) Base64Decode(str string) (string, error) {
                              bytes, err := base64.StdEncoding.DecodeString(str)
                              if err != nil {
                                  return "", fmt.Errorf("base64 decode error: %w", err)
                              }
                          Severity: Minor
                          Found in registry/encoding/functions.go and 1 other location - About 30 mins to fix
                          registry/encoding/functions.go on lines 88..94

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 102.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Similar blocks of code found in 2 locations. Consider refactoring.
                          Open

                          func (er *EncodingRegistry) Base32Decode(str string) (string, error) {
                              bytes, err := base32.StdEncoding.DecodeString(str)
                              if err != nil {
                                  return "", fmt.Errorf("base32 decode error: %w", err)
                              }
                          Severity: Minor
                          Found in registry/encoding/functions.go and 1 other location - About 30 mins to fix
                          registry/encoding/functions.go on lines 48..54

                          Duplicated Code

                          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                          Tuning

                          This issue has a mass of 102.

                          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                          Refactorings

                          Further Reading

                          Severity
                          Category
                          Status
                          Source
                          Language