Skip to content

Commit

Permalink
add linters
Browse files Browse the repository at this point in the history
  • Loading branch information
agbpatro committed Jan 23, 2025
1 parent 9efa0cf commit 5c54c2b
Show file tree
Hide file tree
Showing 41 changed files with 443 additions and 359 deletions.
55 changes: 55 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
run:
timeout: 4m

issues:
exclude-dirs:
- temp

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
15 changes: 12 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
LINTER = golangci-lint run -v $(LINTER_FLAGS) --exclude-use-default=false --timeout $(LINTER_DEADLINE)
LINTER_DEADLINE = 30s
LINTER_FLAGS ?=

all: build

linters: install
@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
8 changes: 4 additions & 4 deletions cmd/tesla-auth-token/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (

func usage() {
w := flag.CommandLine.Output()
fmt.Fprintf(w, "usage: %s [-token-name token_name] [file]\n", filepath.Base(os.Args[0]))
fmt.Fprintln(w, "")
fmt.Fprintln(w, "Reads OAuth token from stdin or file and saves it under token_name in the system")
fmt.Fprintf(w, "keyring. The token_name defaults to $%s.\n", cli.EnvTeslaTokenName)
_, _ = fmt.Fprintf(w, "usage: %s [-token-name token_name] [file]\n", filepath.Base(os.Args[0]))
_, _ = fmt.Fprintln(w, "")
_, _ = fmt.Fprintln(w, "Reads OAuth token from stdin or file and saves it under token_name in the system")
_, _ = fmt.Fprintf(w, "keyring. The token_name defaults to $%s.\n", cli.EnvTeslaTokenName)
}

func main() {
Expand Down
Loading

0 comments on commit 5c54c2b

Please sign in to comment.