Skip to content

Commit

Permalink
Merge branch 'main' into feature/dev-3056-refactor-gogetter-utility-f…
Browse files Browse the repository at this point in the history
…or-better-testability-and
  • Loading branch information
osterman authored Feb 20, 2025
2 parents fd9f35a + 2d1bfac commit 28728c9
Showing 1 changed file with 131 additions and 7 deletions.
138 changes: 131 additions & 7 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,114 @@ run:

linters:
enable:
- funlen # Enforce function length limits
- bodyclose # Check that HTTP response body is closed
- cyclop # Check cyclomatic complexity
- err113 # Detects the use of the deprecated context.Done() method
- errcheck # Check that errors are handled
- forbidigo # Forbid specific function calls
- funlen # Enforce function length limits
- gci # Enforce import ordering
- gocognit # Check cognitive complexity
- gocritic # Enable additional checks for code issues
- errcheck # Check that errors are handled
- godot # Enforce comment formatting
- gofmt # Enforce gofmt style
- gofumpt # Enforce consistent formatting
- goimports # Enforce import formatting
- gosec # Inspect source code for security problems
- govet # Report likely mistakes in code
- staticcheck # Perform static analysis
- revive # Fast, configurable linter
- loggercheck # Enforce structured logging best practices
- misspell # Detect spelling mistakes
- nestif # Detect deeply nested if statements
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
- revive # Fast, configurable linter
- rowserrcheck # Check that rows are closed
- staticcheck # Perform static analysis
- tparallel # Check for parallel test execution
- unconvert # Detect redundant type conversions
- unparam # Detect unused function parameters
- unused # Detect unused variables
- whitespace # Check for leading whitespace
- wsl # Check for whitespace at the end of lines

linters-settings:
funlen:
max-func-lines: 50 # Maximum number of lines per function
statements: 50 # Maximum number of statements per function
functions: 10 # Maximum number of functions per file
lines: 60 # Maximum number of lines per function
statements: 40 # Maximum number of statements per function
ignore-comments: true # Ignore comments when counting lines.

lll:
# Max line length
line-length: 120
# Tab width in spaces when converting tabs
tab-width: 4

gci:
# Configure import ordering
sections:
- standard # Standard library imports
- default # Third party imports
- prefix(your/company/module) # Your module imports

gofmt:
# Simplify code: gofmt -s
simplify: true
# Define indentation
rewrite-rules:
- pattern: "interface{}"
replacement: "any"

cyclop:
# Maximum function complexity
max-complexity: 15
# Skip tests
skip-tests: true

gocognit:
# Maximum cognitive complexity
min-complexity: 20

godot:
# Check if comments end in a period
period: true
# Capital at start of comment
capital: true

revive:
rules:
- name: banned-characters
arguments:
- "goto"
- name: error-strings
arguments:
- disallow-newlines: true
- name: file-length-limit
arguments:
- max: 500 # Max lines per file
skipComments: true
skipBlankLines: true
- name: function-length
arguments: [50, 60] # Max lines per function
- name: cognitive-complexity
arguments: [25] # Max cognitive complexity
- name: cyclomatic
arguments: [10] # Max cyclomatic complexity
- name: add-constant
arguments:
- maxLitCount: "3"
allowStrs: '""'
allowInts: "0,1,2,3,4"
allowFloats: "0.0,0.,1.0,1.,2.0,2."
- name: argument-limit
arguments: [5] # Max arguments per function
- name: deep-exit
- name: early-return
- name: comment-spacings
severity: warning
disabled: false
exclude: [""]
arguments:
- mypragma
- otherpragma

# https://go-critic.com/overview.html
gocritic:
Expand All @@ -37,11 +130,42 @@ linters-settings:
- nestingReduce # Finds where nesting level could be reduced
- preferFilepathJoin # Detects concatenation with os.PathSeparator which can be replaced with filepath.Join

loggercheck:
# Disable built-in checks for other logging libraries
kitlog: false
klog: false
logr: false
slog: false
zap: false

# Enforce structured logging best practices, by requiring all logging keys to be inlined constant strings.
require-string-key: true

# Require printf-like format specifier (%s, %d for example) not present.
no-printf-like: true

# Add custom rules for `charmbracelet/log`
rules:
- (github.com/charmbracelet/log.Logger).Info
- (github.com/charmbracelet/log.Logger).Error
- (github.com/charmbracelet/log.Logger).Warn
- (github.com/charmbracelet/log.Logger).Debug
- (github.com/charmbracelet/log.Logger).Fatal

nestif:
# Minimal complexity of if statements to report.
min-complexity: 4

issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- path: _test\.go$ # Ignore test files for specific linters
linters:
- funlen
- revive
- wsl
- gci

output:
formats:
Expand Down

0 comments on commit 28728c9

Please sign in to comment.