Skip to content

Commit

Permalink
tools: add linter rules
Browse files Browse the repository at this point in the history
Signed-off-by: Doug Hellmann <[email protected]>
  • Loading branch information
dhellmann committed Oct 9, 2020
1 parent cb5c6b6 commit 0c286d6
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.swo
*.swp
.idea/*
tools/bin
32 changes: 32 additions & 0 deletions tools/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
run:
timeout: "5m"

linters:
disable-all: true
enable: [
"govet",
"goimports",
"gofmt",
"staticcheck",
"deadcode",
"dupl",
"errcheck",
"structcheck",
"unparam",
"unused",
"varcheck",
]

linters-settings:
goimports:
local-prefixes: "github.com/openshift/enhancements/tools"
govet:
check-shadowing: false

issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
- linters:
- staticcheck
text: "SA1019:"
13 changes: 13 additions & 0 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
ifeq (/,${HOME})
GOLANGCI_LINT_CACHE=/tmp/golangci-lint-cache/
else
GOLANGCI_LINT_CACHE=${HOME}/.cache/golangci-lint
endif

# Run go lint against code
.PHONY: lint
lint: bin/golangci-lint
GOLANGCI_LINT_CACHE=$(GOLANGCI_LINT_CACHE) ./bin/golangci-lint run --exclude=G101

bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.31.0
2 changes: 1 addition & 1 deletion tools/report/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func fileExists(filename string) bool {
}

func handleError(msg string) {
fmt.Fprintf(os.Stderr, fmt.Sprintf("%s\n", msg))
fmt.Fprintf(os.Stderr, "%s\n", msg)
os.Exit(1)
}

Expand Down
1 change: 0 additions & 1 deletion tools/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ func New(daysBack int, staleMonths int, orgName, repoName string, devMode bool,
type Stats struct {
org string
repo string
minAge int
earliestDate time.Time
staleDate time.Time
devMode bool
Expand Down

0 comments on commit 0c286d6

Please sign in to comment.