From f64ac8f5f7e2c01450b09eda5f660dfa42380350 Mon Sep 17 00:00:00 2001 From: Mathias Fredriksson Date: Wed, 22 Oct 2025 12:10:06 +0300 Subject: [PATCH] chore(scripts/rules.go): ignore db imports in _test.go files (#20406) This change allows us to stop adding the following for every invokation: ``` //nolint:gocritic // This is in a test package and does not end up in the build ``` --- scripts/rules.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/rules.go b/scripts/rules.go index 7fd3c0ca44..0a7c75925d 100644 --- a/scripts/rules.go +++ b/scripts/rules.go @@ -133,7 +133,10 @@ func databaseImport(m dsl.Matcher) { m.Import("github.com/coder/coder/v2/coderd/database") m.Match("database.$_"). Report("Do not import any database types into codersdk"). - Where(m.File().PkgPath.Matches("github.com/coder/coder/v2/codersdk")) + Where( + m.File().PkgPath.Matches("github.com/coder/coder/v2/codersdk") && + !m.File().Name.Matches(`_test\.go$`), + ) } // publishInTransaction detects calls to Publish inside database transactions