Files
coder/.golangci.yaml
Paweł Banaszewski e00e85765b chore: move aibridge library code into coder repo (#24190)
This PR merges code from `coder/aibridge` repository into `coder/coder`.
It was split into 4 PRs for easier review but stacked PRs will need to
be merged into this PR so all checks pass.

* https://github.com/coder/coder/pull/24190 -> raw code copy (this PR,
before merging PRs on top of it, it was just 1 commit:
https://github.com/coder/coder/commit/70d33f33200c7e77df910957595715f81f9bec24)
* https://github.com/coder/coder/pull/24570 -> update imports in
`coder/coder` to use copied code
* https://github.com/coder/coder/pull/24586 -> linter fixes and CI
integration (also added README.md)
* https://github.com/coder/coder/pull/24571 -> added exclude to
scripts/check_emdash.sh check

Original PR message (before PR squash):
Moves coder/aibridge code into coder/coder repository.

Omitted files:

- `go.mod`, `go.sum`, `.gitignore`, `.github/workflows/ci.yml,`
`Makefile`, `LICENSE`, `README.md` (modified README.md is added later)
- `.github`, `example`, `buildinfo,` `scripts` directories

Simple verification script (will list omitted files)

```
tmp=$(mktemp -d)
echo "$tmp"
git clone --depth=1 https://github.com/coder/aibridge "$tmp/aibridge"
git clone --depth=1 --branch pb/aibridge-code-move https://github.com/coder/coder "$tmp/coder"
diff -rq --exclude=.git "$tmp/aibridge" "$tmp/coder/aibridge"
# rm -rf "$tmp"
```
2026-04-22 17:01:01 +02:00

295 lines
7.3 KiB
YAML

# See https://golangci-lint.run/usage/configuration/
# Over time we should try tightening some of these.
linters-settings:
dupl:
# goal: 100
threshold: 412
depguard:
rules:
aibridge_import_isolation:
list-mode: lax
files:
- "aibridge/*.go"
- "aibridge/**/*.go"
allow:
- $gostd
- github.com/coder/coder/v2/aibridge
- github.com/coder/coder/v2/buildinfo
deny:
- pkg: github.com/coder/coder/v2
desc: aibridge code must not import coder packages outside aibridge; buildinfo is the only exception
exhaustruct:
include:
# Gradually extend to cover more of the codebase.
- 'httpmw\.\w+'
# We want to enforce all values are specified when inserting or updating
# a database row. Ref: #9936
- 'github.com/coder/coder/v2/coderd/database\.[^G][^e][^t]\w+Params'
gocognit:
min-complexity: 300
goconst:
min-len: 4 # Min length of string consts (def 3).
min-occurrences: 3 # Min number of const occurrences (def 3).
gocritic:
enabled-checks:
# - appendAssign
# - appendCombine
# - assignOp
# - badCall
- badLock
- badRegexp
- boolExprSimplify
# - builtinShadow
- builtinShadowDecl
# - commentedOutCode
- commentedOutImport
- deferUnlambda
# - deprecatedComment
# - docStub
- dupImport
# - elseif
- emptyFallthrough
# - emptyStringTest
# - equalFold
# - evalOrder
# - exitAfterDefer
# - exposedSyncMutex
# - filepathJoin
- hexLiteral
# - httpNoBody
# - hugeParam
# - ifElseChain
# - importShadow
- indexAlloc
- initClause
- methodExprCall
# - nestingReduce
- nilValReturn
# - octalLiteral
# - paramTypeCombine
# - preferStringWriter
# - preferWriteByte
# - ptrToRefParam
# - rangeExprCopy
# - rangeValCopy
- regexpPattern
# - regexpSimplify
- ruleguard
# - sloppyReassign
- sortSlice
- sprintfQuotedString
- sqlQuery
# - stringConcatSimplify
# - stringXbytes
# - suspiciousSorting
- truncateCmp
- typeAssertChain
# - typeDefFirst
# - typeUnparen
# - unlabelStmt
# - unlambda
# - unnamedResult
# - unnecessaryBlock
# - unnecessaryDefer
# - unslice
- weakCond
# - whyNoLint
# - wrapperFunc
# - yodaStyleExpr
settings:
ruleguard:
failOn: all
rules: "${configDir}/scripts/rules.go"
staticcheck:
# https://staticcheck.io/docs/options#checks
# We disable SA1019 because it gets angry about our usage of xerrors. We
# intentionally xerrors because stack frame support didn't make it into the
# stdlib port.
checks: ["all", "-SA1019"]
goimports:
local-prefixes: coder.com,cdr.dev,go.coder.com,github.com/cdr,github.com/coder
importas:
no-unaliased: true
misspell:
locale: US
ignore-words:
- trialer
nestif:
# goal: 10
min-complexity: 20
revive:
# see https://github.com/mgechev/revive#available-rules for details.
ignore-generated-header: true
severity: warning
rules:
- name: atomic
- name: bare-return
- name: blank-imports
- name: bool-literal-in-expr
- name: call-to-gc
- name: confusing-naming
- name: confusing-results
- name: constant-logical-expr
- name: context-as-argument
- name: context-keys-type
- name: deep-exit
- name: defer
- name: dot-imports
- name: duplicated-imports
- name: early-return
- name: empty-block
- name: empty-lines
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
- name: exported
- name: flag-parameter
- name: get-return
- name: identical-branches
- name: if-return
- name: import-shadowing
- name: increment-decrement
- name: indent-error-flow
# - name: modifies-parameter
- name: modifies-value-receiver
- name: package-comments
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: string-of-int
- name: struct-tag
- name: superfluous-else
- name: time-naming
- name: unconditional-recursion
- name: unexported-naming
- name: unexported-return
- name: unhandled-error
- name: unnecessary-stmt
- name: unreachable-code
- name: unused-parameter
exclude: "**/*_test.go"
- name: unused-receiver
- name: var-declaration
- name: var-naming
- name: waitgroup-by-value
usetesting:
# Only os-setenv is enabled because we migrated to usetesting from another linter that
# only covered os-setenv.
os-setenv: true
os-create-temp: false
os-mkdir-temp: false
os-temp-dir: false
os-chdir: false
context-background: false
context-todo: false
# irrelevant as of Go v1.22: https://go.dev/blog/loopvar-preview
govet:
disable:
- loopclosure
gosec:
excludes:
# Implicit memory aliasing of items from a range statement (irrelevant as of Go v1.22)
- G601
issues:
exclude-dirs:
- node_modules
- .git
exclude-files:
- scripts/rules.go
# Rules listed here: https://github.com/securego/gosec#available-rules
exclude-rules:
- path: _test\.go
linters:
# We use assertions rather than explicitly checking errors in tests
- errcheck
- forcetypeassert
- exhaustruct # This is unhelpful in tests.
- path: scripts/*
linters:
- exhaustruct
- path: scripts/rules.go
linters:
- ALL
fix: true
max-issues-per-linter: 0
max-same-issues: 0
run:
timeout: 10m
# Over time, add more and more linters from
# https://golangci-lint.run/usage/linters/ as the code improves.
linters:
disable-all: true
enable:
- asciicheck
- bidichk
- bodyclose
- depguard
- dogsled
- errcheck
- errname
- errorlint
- exhaustruct
- forcetypeassert
- gocritic
# gocyclo is may be useful in the future when we start caring
# about testing complexity, but for the time being we should
# create a good culture around cognitive complexity.
# - gocyclo
- gocognit
- nestif
- goimports
- gomodguard
- gosec
- gosimple
- govet
- importas
- ineffassign
- makezero
- misspell
- nilnil
- noctx
- paralleltest
- revive
# These don't work until the following issue is solved.
# https://github.com/golangci/golangci-lint/issues/2649
# - rowserrcheck
# - sqlclosecheck
# - structcheck
# - wastedassign
- staticcheck
# 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
# should be able to test most of the functionality from exported functions.
#
# There are edge-cases to this rule, but they should be carefully considered
# to avoid structural inconsistency.
- testpackage
- tparallel
- typecheck
- unconvert
- unused
- usetesting
- dupl