From 492d63b4f0819d4af7007d7a44f97dc30f311fcb Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Wed, 26 Mar 2025 14:37:06 +0000 Subject: [PATCH 1/2] fix: correct spurious edits made during the lint fixing slog --- .golangci.yaml | 31 ++++--------------------------- cmd/coder/main.go | 11 +++++++++++ scripts/migrate-test/main.go | 4 ++-- 3 files changed, 17 insertions(+), 29 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index c735a06170235..9b1c308f44385 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -24,30 +24,19 @@ linters-settings: enabled-checks: # - appendAssign # - appendCombine - - argOrder # - assignOp # - badCall - - badCond - badLock - badRegexp - boolExprSimplify # - builtinShadow - builtinShadowDecl - - captLocal - - caseOrder - - codegenComment # - commentedOutCode - commentedOutImport - - commentFormatting - - defaultCaseOrder - deferUnlambda # - deprecatedComment # - docStub - - dupArg - - dupBranchBody - - dupCase - dupImport - - dupSubExpr # - elseif - emptyFallthrough # - emptyStringTest @@ -56,8 +45,6 @@ linters-settings: # - exitAfterDefer # - exposedSyncMutex # - filepathJoin - - flagDeref - - flagName - hexLiteral # - httpNoBody # - hugeParam @@ -65,47 +52,36 @@ linters-settings: # - importShadow - indexAlloc - initClause - - mapKey - methodExprCall # - nestingReduce - - newDeref - nilValReturn # - octalLiteral - - offBy1 # - paramTypeCombine # - preferStringWriter # - preferWriteByte # - ptrToRefParam # - rangeExprCopy # - rangeValCopy - - regexpMust - regexpPattern # - regexpSimplify - ruleguard - - singleCaseSwitch - - sloppyLen # - sloppyReassign - - sloppyTypeAssert - sortSlice - sprintfQuotedString - sqlQuery # - stringConcatSimplify # - stringXbytes # - suspiciousSorting - - switchTrue - truncateCmp - typeAssertChain # - typeDefFirst - - typeSwitchVar # - typeUnparen - - underef # - unlabelStmt # - unlambda # - unnamedResult # - unnecessaryBlock # - unnecessaryDefer # - unslice - - valSwap - weakCond # - whyNoLint # - wrapperFunc @@ -224,6 +200,9 @@ issues: - path: scripts/* linters: - exhaustruct + - path: scripts/rules.go + linters: + - ALL fix: true max-issues-per-linter: 0 @@ -231,8 +210,6 @@ issues: run: timeout: 10m - skip-files: - - scripts/rules.go # Over time, add more and more linters from # https://golangci-lint.run/usage/linters/ as the code improves. @@ -277,7 +254,6 @@ linters: # - wastedassign - staticcheck - - tenv # In Go, it's possible for a package to test it's internal functionality # without testing any exported functions. This is enabled to promote # decomposing a package before testing it's internals. A function caller @@ -290,4 +266,5 @@ linters: - typecheck - unconvert - unused + - usetesting - dupl diff --git a/cmd/coder/main.go b/cmd/coder/main.go index 0fcbf38721947..4a575e5a3af5b 100644 --- a/cmd/coder/main.go +++ b/cmd/coder/main.go @@ -1,15 +1,26 @@ package main import ( + "fmt" + "os" _ "time/tzdata" + tea "github.com/charmbracelet/bubbletea" + + "github.com/coder/coder/v2/agent/agentexec" _ "github.com/coder/coder/v2/buildinfo/resources" "github.com/coder/coder/v2/cli" ) func main() { + if len(os.Args) > 1 && os.Args[1] == "agent-exec" { + err := agentexec.CLI() + _, _ = fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } // This preserves backwards compatibility with an init function that is causing grief for // web terminals using agent-exec + screen. See https://github.com/coder/coder/pull/15817 + tea.InitTerminal() var rootCmd cli.RootCmd rootCmd.RunWithSubcommands(rootCmd.AGPL()) diff --git a/scripts/migrate-test/main.go b/scripts/migrate-test/main.go index 889bc89f9dfcf..a0c03483e9e9c 100644 --- a/scripts/migrate-test/main.go +++ b/scripts/migrate-test/main.go @@ -95,12 +95,12 @@ func main() { dumpBytesAfter, err := dbtestutil.PGDumpSchemaOnly(postgresURL) if err != nil { friendlyError(os.Stderr, err, migrateFromVersion, migrateToVersion) - panic("") + panic(err) } if diff := cmp.Diff(string(dumpBytesAfter), string(stripGenPreamble(expectedSchemaAfter))); diff != "" { friendlyError(os.Stderr, xerrors.Errorf("Schema differs from expected after migration: %s", diff), migrateFromVersion, migrateToVersion) - panic("") + panic(err) } _, _ = fmt.Fprintf(os.Stderr, "OK\n") } From c79d82b71edb1f299b0fca5bf5f03dd964c1182c Mon Sep 17 00:00:00 2001 From: Jon Ayers Date: Thu, 27 Mar 2025 05:25:20 +0000 Subject: [PATCH 2/2] fix warnings --- .golangci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.golangci.yaml b/.golangci.yaml index 9b1c308f44385..bf8f0b9becae5 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -184,7 +184,7 @@ issues: - node_modules - .git - skip-files: + exclude-files: - scripts/rules.go # Rules listed here: https://github.com/securego/gosec#available-rules @@ -254,6 +254,7 @@ linters: # - wastedassign - staticcheck + - tenv # In Go, it's possible for a package to test it's internal functionality # without testing any exported functions. This is enabled to promote # decomposing a package before testing it's internals. A function caller @@ -266,5 +267,4 @@ linters: - typecheck - unconvert - unused - - usetesting - dupl