Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
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
14 changes: 13 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,44 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: fmt
uses: ./ci/image
with:
args: make -j fmt

- run: ./ci/scripts/files_changed.sh

lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- name: golangci-lint
uses: golangci/golangci-lint-action@v2.5.2
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.36
version: v1.39

test:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: test
uses: ./ci/image
env:
Expand All @@ -45,18 +53,22 @@ jobs:
CODER_PASSWORD: ${{ secrets.CODER_PASSWORD }}
with:
args: make -j test/coverage

gendocs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: generate-docs
uses: ./ci/image
with:
args: make -j gendocs

- run: ./ci/scripts/files_changed.sh
157 changes: 102 additions & 55 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,73 +1,120 @@
# See https://golangci-lint.run/usage/configuration/
linters-settings:
goconst:
min-len: 4
min-occurrences: 3
gocognit:
# tunnel.go has a 150 line function. Someone should fix it and
# decrement this back down to a rational number.
min-complexity: 52
goconst:
min-len: 4
min-occurrences: 3
nestif:
min-complexity: 10
govet:
settings:
printf:
funcs: # Run `go tool vet help printf` to see available settings for `printf` analyzer.
- (cdr.dev/coder-cli/pkg/clog).Tipf
- (cdr.dev/coder-cli/pkg/clog).Hintf
- (cdr.dev/coder-cli/pkg/clog).Causef
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: range-val-address
- name: range-val-in-closure
- 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
# - name: unused-receiver
# - name: var-declaration
- name: var-naming
- name: waitgroup-by-value

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

run:
timeout: 5m

linters:
disable-all: true
exclude-use-default: false
enable:
- megacheck
- govet
- golint
- goconst
- gocognit
- nestif
- misspell
- unparam
- unused
- bodyclose
- deadcode
- depguard
- dogsled
- errcheck
- unconvert
- unparam
- varcheck
- whitespace
# - errorlint
- exportloopref
# - forcetypeassert
- gocognit
- goconst
- gocritic
- gocyclo
- godot
- gofmt
- goimports
- golint
- gomodguard
- goprintffuncname
# - gosec
- gosimple
- govet
- ineffassign
- makezero
- megacheck
- misspell
- nestif
- noctx
- nolintlint
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- nolintlint
- rowserrcheck
- scopelint
- goprintffuncname
- gofmt
- godot
- ineffassign
- gocritic

issues:
exclude-use-default: false
exclude:
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
# golint: False positive when tests are defined in package 'test'
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
# govet: Common false positives
- (possible misuse of unsafe.Pointer|should have signature)
# staticcheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
- ineffective break statement. Did you mean to break out of the outer loop
# gosec: Too many false-positives on 'unsafe' usage
- Use of unsafe calls should be audited
# gosec: Too many false-positives for parametrized shell calls
- Subprocess launch(ed with variable|ing should be audited)
# gosec: Duplicated errcheck checks
- G104
# gosec: Too many issues in popular repos
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
# gosec: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
- Potential file inclusion via variable
- unconvert
- unparam
- unused
- varcheck
- wastedassign
- whitespace