-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from vansante/golint-ci
Use golangci-lint for all linting purposes (adds more static code analysis)
- Loading branch information
Showing
6 changed files
with
75 additions
and
45 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
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 |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea | ||
.idea | ||
/bin |
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,55 @@ | ||
run: | ||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
deadline: 30s | ||
|
||
# exit code when at least one issue was found, default is 1 | ||
issues-exit-code: 1 | ||
|
||
# include test files or not, default is true | ||
tests: true | ||
|
||
# all available settings of specific linters | ||
linters-settings: | ||
gocyclo: | ||
min-complexity: 20 | ||
maligned: | ||
suggest-new: true | ||
dupl: | ||
threshold: 100 | ||
goconst: | ||
min-len: 3 | ||
min-occurrences: 2 | ||
depguard: | ||
lll: | ||
line-length: 160 | ||
nakedret: | ||
max-func-lines: 10 | ||
|
||
linters: | ||
enable: | ||
- megacheck | ||
- govet | ||
- golint | ||
- gosec | ||
- unconvert | ||
- goconst | ||
- gocyclo | ||
- gofmt | ||
- maligned | ||
- lll | ||
- unparam | ||
- nakedret | ||
- misspell | ||
enable-all: false | ||
disable-all: false | ||
presets: | ||
- bugs | ||
- unused | ||
fast: false | ||
|
||
issues: | ||
exclude-rules: | ||
- path: probedata\.go | ||
text: "ALL_CAPS" | ||
linters: | ||
- golint |
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 |
---|---|---|
@@ -1,48 +1,21 @@ | ||
SHELL:=$(PREFIX)/bin/bash | ||
GOLANGCILINT := $(shell command -v ./bin/golangci-lint 2> /dev/null) | ||
|
||
all: verify test | ||
|
||
verify: fmt vet lint nakedreturns duplicatecode constants | ||
all: lint test | ||
|
||
clean: | ||
# Cleaning test cache | ||
go clean -testcache | ||
|
||
fmt: | ||
# Checking project code formatting... | ||
! gofmt -d . | read || ( gofmt -d . && exit 1 ) | ||
|
||
vet: | ||
# Checking for suspicious constructs | ||
go vet ./... | ||
|
||
lint: | ||
@command -v golint >/dev/null 2>&1 || go get github.com/golang/lint/golint | ||
# Checking project code style... | ||
! ( golint ./... | grep -v "ALL_CAPS" ) | ||
|
||
imports: | ||
@command -v goimports >/dev/null 2>&1 || go get golang.org/x/tools/cmd/goimports | ||
# Fixing imports | ||
goimports -w . | ||
|
||
nakedreturns: | ||
@command -v nakedret >/dev/null 2>&1 || go get github.com/alexkohler/nakedret | ||
# Checking for naked returns | ||
! nakedret ./... 2>&1 | read || ( nakedret ./... && exit 1 ) | ||
|
||
duplicatecode: | ||
@command -v dupl >/dev/null 2>&1 || go get github.com/mibk/dupl | ||
# Checking for duplicate code | ||
! find . -name '*.go' | grep -v '_test.go' | dupl -t 75 -plumbing -files | read || ( find . -name '*.go' | grep -v '_test.go' | dupl -t 75 -files && exit 1 ) | ||
|
||
constants: | ||
@command -v goconst >/dev/null 2>&1 || go get github.com/jgautheron/goconst/cmd/goconst | ||
# Checking for possible constants | ||
! goconst ./... | read || ( goconst ./... && exit 1 ) | ||
ifndef GOLANGCILINT | ||
# golangci-lint not installed, downloading... | ||
go get github.com/golangci/golangci-lint | ||
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s v1.15.0 | ||
endif | ||
./bin/golangci-lint run | ||
|
||
test: | ||
# Running tests | ||
go test -v -timeout 10s -race ./... | ||
|
||
.PHONY: all verify clean fmt vet lint imports nakedreturns duplicatecode constants test | ||
.PHONY: all clean lint test |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
module github.com/vansante/go-ffprobe | ||
|
||
go 1.12 |