From cc84f9ec9f03c5331cd036c5e38b0c8354aef612 Mon Sep 17 00:00:00 2001 From: Mauri de Souza Meneguzzo Date: Thu, 30 Jan 2025 15:21:37 -0300 Subject: [PATCH] chore: add linter that denies importing math/rand (#6650) --- .golangci.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 6047e1829ba..bcfef9a3d8f 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -54,7 +54,8 @@ linters: - noctx # noctx finds sending http request without context.Context - unconvert # Remove unnecessary type conversions - wastedassign # wastedassign finds wasted assignment statements. - - gomodguard # check for blocked dependencies + - depguard # check for blocked imports from Go files + - gomodguard # check for blocked imports from go.mod - gomoddirectives # all available settings of specific linters @@ -88,9 +89,9 @@ linters-settings: goimports: local-prefixes: github.com/elastic + # Check for blocked dependencies in go.mod. gomodguard: blocked: - # List of blocked modules. modules: # Blocked module. - github.com/pkg/errors: @@ -105,6 +106,15 @@ linters-settings: - github.com/gofrs/uuid/v5 reason: "Use one uuid library consistently across the codebase" + # Check for blocked imports in Go files. + depguard: + rules: + main: + list-mode: lax + deny: + - pkg: "math/rand$" + desc: "superseded by math/rand/v2" + gomoddirectives: # Forbid local `replace` directives replace-local: false