Skip to content

Commit

Permalink
add linters (#361)
Browse files Browse the repository at this point in the history
  • Loading branch information
agbpatro authored Jan 24, 2025
1 parent 3f5835b commit 29fe990
Show file tree
Hide file tree
Showing 39 changed files with 411 additions and 319 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,13 @@ jobs:
make format
git diff --exit-code
- name: Setup golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.61.0

- name: Linter passes
run: make linters

- name: Test
run: make test
61 changes: 61 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
run:
timeout: 4m

issues:
exclude-dirs:
- temp
exclude:
- "Error return value of `w.Write` is not checked"
- "Error return value of `fmt.Fprintf` is not checked"
- "Error return value of `fmt.Fprintln` is not checked"
- "Error return value of `file.Close` is not checked"
- "Error return value of `os.Setenv` is not checked"

linters:
enable:
- errcheck
- gofmt
- gosimple
- govet
- misspell
- revive
- unused
disable:
# Remove from disable when all issues are fixed
- staticcheck

linters-settings:
revive:
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
arguments:
- allowedPackages:
- "github.com/onsi/ginkgo"
- "github.com/onsi/ginkgo/v2"
- "github.com/onsi/gomega"
- name: empty-block
- name: error-naming
- name: error-return
- name: error-strings
- name: errorf
# Uncomment when all issues are fixed
# - name: exported
- name: increment-decrement
- name: indent-error-flow
- name: package-comments
disabled: true
- name: range
- name: receiver-naming
- name: redefines-builtin-id
- name: superfluous-else
- name: time-naming
# Uncomment when all issues are fixed
# - name: unexported-return
- name: unreachable-code
- name: unused-parameter
- name: var-declaration
- name: var-naming
19 changes: 16 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
LINTER = golangci-lint run -v $(LINTER_FLAGS) --exclude-use-default=false --timeout $(LINTER_DEADLINE)
LINTER_DEADLINE = 30s
LINTER_FLAGS ?=

ifneq (,$(wildcard /etc/alpine-release))
LINTER_FLAGS += --build-tags=musl
endif

all: build

linters:
@echo "** Running linters...**"
$(LINTER)
@echo "** SUCCESS **"

set-version:
if TAG=$$(git describe --tags --abbrev=0); then echo "$${TAG}" | sed 's/v//' > pkg/account/version.txt; fi

format: set-version
go fmt ./...

test:
test: install
go test -cover ./...
go vet ./...

build: set-version test
go build ./...

install: test
install:
go install ./cmd/...

doc-images:
docker run -v ./:/data plantuml/plantuml "doc"

.PHONY: install build test format set-version doc-images
.PHONY: install build linters test format set-version doc-images
Loading

0 comments on commit 29fe990

Please sign in to comment.