Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# Based on the Coder repo lint profile, trimmed to the checks that make sense
# for the standalone aibridge module.

linters-settings:
dupl:
threshold: 412

exhaustruct:
include:
- 'httpmw\.\w+'

gocognit:
min-complexity: 300

goconst:
min-len: 4
min-occurrences: 3

gocritic:
enabled-checks:
- badLock
- badRegexp
- boolExprSimplify
- builtinShadowDecl
- commentedOutImport
- deferUnlambda
- dupImport
- emptyFallthrough
- hexLiteral
- indexAlloc
- initClause
- methodExprCall
- nilValReturn
- regexpPattern
- ruleguard
- sortSlice
- sprintfQuotedString
- sqlQuery
- truncateCmp
- typeAssertChain
- weakCond
settings:
ruleguard:
failOn: all
rules: "${configDir}/scripts/rules.go"

staticcheck:
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:
min-complexity: 20

revive:
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-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:
os-setenv: true
os-create-temp: false
os-mkdir-temp: false
os-temp-dir: false
os-chdir: false
context-background: false
context-todo: false

govet:
disable:
- loopclosure

gosec:
excludes:
- G601

issues:
fix: true

exclude-dirs:
- .git

exclude-files:
- scripts/rules.go

exclude-rules:
- path: _test\.go
linters:
- errcheck
- forcetypeassert
- exhaustruct
- path: scripts/*
linters:
- exhaustruct
- path: scripts/rules.go
linters:
- ALL

max-issues-per-linter: 0
max-same-issues: 0

run:
timeout: 10m

linters:
disable-all: true
enable:
- asciicheck
- bidichk
- bodyclose
- dogsled
- errcheck
- errname
- errorlint
- exhaustruct
- forcetypeassert
- gocognit
- gocritic
- goimports
- gomodguard
- gosec
- gosimple
- govet
- importas
- ineffassign
- makezero
- misspell
- nestif
- nilnil
- noctx
- paralleltest
- revive
- staticcheck
- testpackage
- tparallel
- typecheck
- unconvert
- unused
- usetesting
- dupl
23 changes: 21 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Use a single bash shell for each job, and immediately exit on failure
.SHELL := /usr/bin/env bash
SHELL := bash
.SHELLFLAGS := -ceu
.ONESHELL:

Expand All @@ -13,6 +13,25 @@ ifndef VERBOSE
.SILENT:
endif

SHELL_SRC_FILES := $(shell find . -type f -name '*.sh' -not -path '*/.git/*')
GOLANGCI_LINT_VERSION ?= 1.64.8
PARALLELTESTCTX_VERSION ?= 0.0.1

lint: lint/shellcheck lint/go
.PHONY: lint

lint/go:
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v$(GOLANGCI_LINT_VERSION) run
go run github.com/coder/paralleltestctx/cmd/paralleltestctx@v$(PARALLELTESTCTX_VERSION) -custom-funcs="testutil.Context" ./...
.PHONY: lint/go

lint/shellcheck:
if test -n "$(strip $(SHELL_SRC_FILES))"; then \
echo "--- shellcheck"; \
shellcheck --external-sources $(SHELL_SRC_FILES); \
fi
.PHONY: lint/shellcheck

test:
go test -count=1 ./...

Expand Down Expand Up @@ -48,4 +67,4 @@ endif
.PHONY: fmt/go

mocks: mcp/api.go
go generate ./mcpmock/
go generate ./mcpmock/
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/mark3labs/mcp-go v0.38.0
github.com/prometheus/client_golang v1.23.2
github.com/quasilyte/go-ruleguard/dsl v0.3.23
github.com/sony/gobreaker/v2 v2.3.0
github.com/stretchr/testify v1.11.1
github.com/tidwall/gjson v1.18.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ github.com/prometheus/common v0.66.1 h1:h5E0h5/Y8niHc5DlaLlWLArTQI7tMrsfQjHV+d9Z
github.com/prometheus/common v0.66.1/go.mod h1:gcaUsgf3KfRSwHY4dIMXLPV0K/Wg1oZ8+SbZk/HH/dA=
github.com/prometheus/procfs v0.16.1 h1:hZ15bTNuirocR6u0JZ6BAHHmwS1p8B4P6MRqxtzMyRg=
github.com/prometheus/procfs v0.16.1/go.mod h1:teAbpZRB1iIAJYREa1LsoWUXykVXA1KlTmWl8x/U+Is=
github.com/quasilyte/go-ruleguard/dsl v0.3.23 h1:lxjt5B6ZCiBeeNO8/oQsegE6fLeCzuMRoVWSkXC4uvY=
github.com/quasilyte/go-ruleguard/dsl v0.3.23/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis=
Expand Down
Loading
Loading