-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also add GitHub Action for lint
- Loading branch information
Showing
18 changed files
with
369 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: code quality | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version-file: 'go.mod' | ||
|
||
- name: ensure go mod tidy | ||
run: go mod tidy && git diff --exit-code go.mod go.sum | ||
|
||
- name: get linter version | ||
id: linter-version | ||
run: echo "version=$(grep 'LINTER_VERSION :=' Makefile | awk '{print $3}')" > $GITHUB_OUTPUT | ||
|
||
- name: lint | ||
uses: golangci/golangci-lint-action@v3 | ||
with: | ||
version: v${{ steps.linter-version.outputs.version }} | ||
args: --timeout=15m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
linters-settings: | ||
dupl: | ||
threshold: 100 | ||
exhaustive: | ||
default-signifies-exhaustive: true | ||
funlen: | ||
lines: 100 | ||
statements: 50 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
gocyclo: | ||
min-complexity: 15 | ||
goimports: | ||
local-prefixes: github.com/kylrth/api | ||
gomnd: | ||
settings: | ||
mnd: | ||
# don't include the "operation" and "assign" | ||
checks: argument,case,condition,return | ||
govet: | ||
check-shadowing: true | ||
enable-all: true | ||
disable: | ||
- fieldalignment | ||
ireturn: | ||
allow: | ||
- error | ||
- generic | ||
lll: | ||
line-length: 100 | ||
misspell: | ||
locale: US | ||
nolintlint: | ||
allow-unused: false | ||
allow-leading-space: false | ||
require-explanation: true | ||
require-specific: true | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- asasalint | ||
- asciicheck | ||
- bidichk | ||
- bodyclose | ||
- containedctx | ||
- contextcheck | ||
- cyclop | ||
- decorder | ||
- dogsled | ||
- dupl | ||
- dupword | ||
- durationcheck | ||
- errcheck | ||
- errchkjson | ||
- errname | ||
- errorlint | ||
- execinquery | ||
- exhaustive | ||
- exportloopref | ||
- forcetypeassert | ||
- funlen | ||
- ginkgolinter | ||
- gocheckcompilerdirectives | ||
- gocognit | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- godot | ||
- godox | ||
- gofmt | ||
- gofumpt | ||
- goimports | ||
- gomoddirectives | ||
- gomodguard | ||
- goprintffuncname | ||
- gosec | ||
- gosmopolitan | ||
- gosimple | ||
- grouper | ||
- govet | ||
- importas | ||
- interfacebloat | ||
- ineffassign | ||
- ireturn | ||
- lll | ||
- loggercheck | ||
- maintidx | ||
- makezero | ||
- mirror | ||
- misspell | ||
- musttag | ||
- nakedret | ||
- nestif | ||
- nilerr | ||
- nilnil | ||
- nlreturn | ||
- noctx | ||
- nolintlint | ||
- nosprintfhostport | ||
- paralleltest | ||
- prealloc | ||
- predeclared | ||
- promlinter | ||
- reassign | ||
- revive | ||
- rowserrcheck | ||
- sqlclosecheck | ||
- staticcheck | ||
- stylecheck | ||
- tagalign | ||
- tenv | ||
- testableexamples | ||
- testpackage | ||
- thelper | ||
- tparallel | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused | ||
- usestdlibvars | ||
- wastedassign | ||
- whitespace | ||
- zerologlint | ||
# not enabled: | ||
# - deadcode # deprecated | ||
# - depguard # We have no restrictions on dependencies. | ||
# - exhaustivestruct # deprecated | ||
# - exhaustruct # This doesn't make sense to check for in most cases. | ||
# - forbidigo # nothing to forbid | ||
# - gci # prefer goimports | ||
# - gochecknoglobals # I don't think globals should be universally disallowed. | ||
# - gochecknoinits # I don't think init should be universally disallowed. | ||
# - goerr113 # I think it's ok to include info in errors without defining a new type. | ||
# - goheader # no need for a header | ||
# - golint # deprecated | ||
# - gomnd # prefer goconst | ||
# - ifshort # deprecated | ||
# - interfacer # deprecated | ||
# - maligned # deprecated | ||
# - nonamedreturns # disagree | ||
# - nosnakecase # deprecated | ||
# - scopelint # deprecated | ||
# - structcheck # deprecated | ||
# - tagliatelle # We have to use the JSON fields from the API. | ||
# - varcheck # deprecated | ||
# - varnamelen # I don't think this matters. | ||
# - wrapcheck # I think this should only happen for public functions. | ||
# - wsl # not a fan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
all: lint build | ||
|
||
BINDIR := bin | ||
|
||
## LINT | ||
|
||
LINTER_VERSION := 1.53.3 | ||
LINTER := $(BINDIR)/golangci-lint_$(LINTER_VERSION) | ||
DEV_OS := $(shell uname -s | tr A-Z a-z) | ||
|
||
$(LINTER): | ||
mkdir -p $(BINDIR) | ||
wget "https://github.com/golangci/golangci-lint/releases/download/v$(LINTER_VERSION)/golangci-lint-$(LINTER_VERSION)-$(DEV_OS)-amd64.tar.gz" -O - \ | ||
| tar -xz -C $(BINDIR) --strip-components=1 --exclude=README.md --exclude=LICENSE | ||
mv $(BINDIR)/golangci-lint $(LINTER) | ||
|
||
.PHONY: lint | ||
lint: $(LINTER) | ||
$(LINTER) run --deadline=2m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.