go-sprout/sprout

View on GitHub

Showing 15 of 49 total issues

Function parseCodeBlock has a Cognitive Complexity of 51 (exceeds 20 allowed). Consider refactoring.
Open

func parseCodeBlock(codeBlock, funcName, filePath string) []Example {
    var examples []Example
    lines := strings.Split(codeBlock, "\n")

    i := 0
Severity: Minor
Found in tools/docvalidator/parsing.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 parseCodeBlock has 85 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func parseCodeBlock(codeBlock, funcName, filePath string) []Example {
    var examples []Example
    lines := strings.Split(codeBlock, "\n")

    i := 0
Severity: Major
Found in tools/docvalidator/parsing.go - About 2 hrs to fix

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

    func (sr *StringsRegistry) transformString(style caseStyle, value string) string {
        var result strings.Builder
        result.Grow(len(value) + 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(size int, opts *randomOpts) string {
        if size <= 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 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, value 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

        Function run has 7 return statements (exceeds 4 allowed).
        Open

        func run(fs FileSystem) error {
            // Set the log level based on the flag
            if err := setLogLevel(logLevel); err != nil {
                return err
            }
        Severity: Major
        Found in tools/docvalidator/main.go - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if nextLine == "" || strings.HasPrefix(nextLine, "{{") || strings.Contains(nextLine, "// Output:") || strings.Contains(nextLine, "// Error") {
                                  i--
                                  break
                              }
          Severity: Major
          Found in tools/docvalidator/parsing.go - About 45 mins to fix

            Function processExample has 7 return statements (exceeds 4 allowed).
            Open

            func processExample(example Example) error {
                if example.Skipped {
                    return nil
                }
            
            
            Severity: Major
            Found in tools/docvalidator/processing.go - About 45 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

                  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 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

                      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
                        Severity
                        Category
                        Status
                        Source
                        Language