Skip to content

Commit

Permalink
Add linting and formatting configurations with makefile
Browse files Browse the repository at this point in the history
Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net>
  • Loading branch information
sambhav committed Jun 28, 2021
1 parent c07e39f commit 076d273
Show file tree
Hide file tree
Showing 5 changed files with 1,136 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Go parameters
GOCMD?=go
GO_VERSION=$(shell go list -m -f "{{.GoVersion}}")
PACKAGE_BASE=github.com/buildpacks/libcnb

all: test

install-goimports:
@echo "> Installing goimports..."
cd tools && $(GOCMD) install golang.org/x/tools/cmd/goimports

format: install-goimports
@echo "> Formating code..."
@goimports -l -w -local ${PACKAGE_BASE} .

install-golangci-lint:
@echo "> Installing golangci-lint..."
cd tools && $(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint

lint: install-golangci-lint
@echo "> Linting code..."
@golangci-lint run -c golangci.yaml

test: format lint
$(GOCMD) test -parallel=1 -count=1 -v ./...
32 changes: 32 additions & 0 deletions golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
run:
timeout: 6m

linters:
disable-all: true
enable:
- bodyclose
- deadcode
- dogsled
- gocritic
- goimports
- golint
- gosec
- gosimple
- govet
- ineffassign
- maligned
- misspell
- nakedret
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unused
- varcheck
- whitespace

linters-settings:
goimports:
local-prefixes: github.com/buildpacks/libcnb
7 changes: 7 additions & 0 deletions tools/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module github.com/buildpacks/libcnb/tools

go 1.15

require golang.org/x/tools v0.1.4

require github.com/golangci/golangci-lint v1.41.1
Loading

0 comments on commit 076d273

Please sign in to comment.