chore: add workspace activity linter (#13273)

This commit is contained in:
Garrett Delfosse
2024-05-14 12:31:31 -04:00
committed by GitHub
parent 2b29559984
commit 721ab2a1b4
7 changed files with 26 additions and 0 deletions
+20
View File
@@ -467,3 +467,23 @@ func withTimezoneUTC(m dsl.Matcher) {
).Report(`Setting database timezone to UTC may mask timezone-related bugs.`).
At(m["tz"])
}
// workspaceActivity ensures that updating workspace activity is only done in the workspaceapps package.
//
//nolint:unused,deadcode,varnamelen
func workspaceActivity(m dsl.Matcher) {
m.Import("github.com/coder/coder/v2/coderd/database")
m.Match(
`$_.ActivityBumpWorkspace($_, $_)`,
`$_.UpdateWorkspaceLastUsedAt($_, $_)`,
`$_.BatchUpdateWorkspaceLastUsedAt($_, $_)`,
`$_.UpdateTemplateWorkspacesLastUsedAt($_, $_)`,
`$_.InsertWorkspaceAgentStats($_, $_)`,
`$_.InsertWorkspaceAppStats($_, $_)`,
).Where(
!m.File().PkgPath.Matches(`workspaceapps`) &&
!m.File().PkgPath.Matches(`dbauthz$`) &&
!m.File().PkgPath.Matches(`dbgen$`) &&
!m.File().Name.Matches(`_test\.go$`),
).Report("Updating workspace activity should always be done in the workspaceapps package.")
}