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
- Read upRead up
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
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
- Read upRead up
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 ""
}
- Read upRead up
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:
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)
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 == "" {
- Read upRead up
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
}
Avoid deeply nested control flow statements. Open
if nextLine == "" || strings.HasPrefix(nextLine, "{{") || strings.Contains(nextLine, "// Output:") || strings.Contains(nextLine, "// Error") {
i--
break
}
Function processExample
has 7 return statements (exceeds 4 allowed). Open
func processExample(example Example) error {
if example.Skipped {
return nil
}
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)
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,
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)
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)
Function StrSlice
has 5 return statements (exceeds 4 allowed). Open
func StrSlice(value any) []string {
if value == nil {
return []string{}
}