Codequality
Recipes
- Add exported func comment
- Allocate map outside loop
- Allocate outside loop
- Audit HTTP redirect
- Audit Must* function calls
- Audit TestMain
- Audit channel close
- Audit context.Background
- Audit exec.Command calls
- Audit goroutine closure
- Audit json.Number
- Audit json.RawMessage
- Audit recover() calls
- Audit test fatal
- Audit yaml.Unmarshal
- Avoid SQL string concatenation
- Avoid channel length check
- Avoid context.WithValue
- Avoid defer in loop
- Avoid dot imports
- Avoid empty interface parameters
- Avoid fmt in loop
- Avoid format string variable
- Avoid global variables
- Avoid hardcoded credentials
- Avoid init functions
- Avoid lock in loop
- Avoid log.Fatal
- Avoid nested goroutine
- Avoid os.Exit
- Avoid panic
- Avoid reflection
- Avoid time.Sleep
- Avoid unsafe package
- Check Close() error
- Check context error
- Check template execute error
- Compile regex outside loop
- Create channel outside loop
- Ensure SQL connection closed
- Ensure file closed
- Find deprecated
sync/atomicfunctions - Find potentially redundant type conversion
- Handle checked error
- Handle deferred Close() error
- Handle error return value
- Handle swallowed error
- Keep functions short
- Keep interfaces small
- Limit function parameters
- Limit goroutines in loop
- Limit return values
- Merge collapsible if statements
- Merge identical branches
- Preallocate slice
- Prefer %w over %s in fmt.Errorf for error wrapping
- Prefer buf.String() over string(buf.Bytes())
- Prefer bytes.Contains over bytes.Index comparison
- Prefer bytes.ContainsAny
- Prefer bytes.ContainsRune
- Prefer bytes.Equal
- Prefer bytes.HasPrefix
- Prefer canonical len check
- Prefer copy from string
- Prefer empty string check
- Prefer errors.Is for context error comparison
- Prefer errors.Is for io.EOF comparison
- Prefer errors.Is for os existence checks
- Prefer errors.Is for os permission checks
- Prefer errors.Is for os timeout checks
- Prefer errors.Is for package-qualified sentinel comparison
- Prefer errors.Is over == for error comparison
- Prefer filepath.Clean over redundant filepath.Join
- Prefer hex.EncodeToString over fmt.Sprintf
- Prefer io.Discard
- Prefer io.NopCloser
- Prefer io.ReadAll
- Prefer io.WriteString
- Prefer make() for empty maps
- Prefer min/max builtins
- Prefer os.CreateTemp
- Prefer os.MkdirTemp
- Prefer os.ReadDir
- Prefer os.ReadFile
- Prefer os.WriteFile
- Prefer raw string literals for regex patterns
- Prefer regexp.MustCompile for unchecked patterns
- Prefer slices.Sort over sort type helpers
- Prefer sort.Ints over sort.Sort(sort.IntSlice)
- Prefer strconv.Atoi
- Prefer strconv.FormatBool over fmt.Sprintf
- Prefer strconv.Itoa over fmt.Sprintf
- Prefer strconv.Quote over fmt.Sprintf
- Prefer strings.Builder WriteString
- Prefer strings.Contains over strings.Count
- Prefer strings.Contains over strings.Index comparison
- Prefer strings.ContainsAny
- Prefer strings.ContainsRune
- Prefer strings.EqualFold
- Prefer strings.EqualFold (single-sided)
- Prefer strings.HasPrefix
- Prefer strings.NewReader
- Reduce error check nesting
- Reduce nesting depth
- Remove constant if condition
- Remove debug print statements
- Remove duplicate conditions
- Remove empty default case
- Remove empty fmt.Sprintf
- Remove empty for loop
- Remove empty functions
- Remove empty goroutine
- Remove empty switch
- Remove getter prefix
- Remove if/else with identical branches
- Remove package prefix from name
- Remove redundant *& (deref of address-of)
- Remove redundant break
- Remove redundant break in select
- Remove redundant else after return
- Remove redundant fmt.Sprintf
- Remove redundant range blank
- Remove redundant return
- Remove redundant type assertion to empty interface
- Remove self-assignment
- Remove switch true tag
- Remove unconditional value overwrite
- Remove unreachable code
- Replace extra %w verbs with %v in fmt.Errorf
- Replace map range-delete with clear()
- Replace t.Sub(time.Now()) with time.Until(t)
- Replace time.Now().Sub(t) with time.Since(t)
- Resolve context.TODO
- Reuse JSON codec in loop
- Simplify boolean expression
- Simplify bytes.Equal nil check
- Simplify bytes.NewBuffer roundtrip
- Simplify bytes.SplitN with -1
- Simplify double negation
- Simplify errors.Is nil check
- Simplify fmt.Sprintf %c to string conversion
- Simplify fmt.Sprintf string concat
- Simplify fmt.Sprintf with %%v
- Simplify goroutine closure
- Simplify if-return-bool
- Simplify nil check before Close
- Simplify no-op TrimLeft/TrimRight
- Simplify redundant TrimSpace
- Simplify redundant bytes.TrimSpace
- Simplify redundant error wrap
- Simplify redundant len check before range
- Simplify redundant logical expression
- Simplify redundant nil check
- Simplify select default only
- Simplify single-case select
- Simplify slice range
- Simplify strings.SplitN with -1
- Use .Error() method
- Use Err prefix for errors
- Use MixedCaps
- Use MixedCaps for constants
- Use TLS for HTTP
- Use buffered channel
- Use bytes.ReplaceAll
- Use comma-ok type assertion
- Use crypto/rand
- Use ctx for context.Context parameter
- Use custom HTTP client
- Use descriptive package name
- Use descriptive variable names
- Use documented blank imports
- Use errors.As
- Use errors.Is over string comparison
- Use errors.New for simple errors
- Use http.NewRequestWithContext
- Use http.Server with timeouts
- Use meaningful return values
- Use named constants
- Use package-level error sentinel
- Use short receiver name
- Use skip with reason
- Use strings.Builder in loop
- Use strings.ReplaceAll
- Use structured logging
- Wrap error before return
- Wrap error with context