From b77b626665251a7e5fee6c8df83d7d68b12e3da0 Mon Sep 17 00:00:00 2001 From: David Bariod Date: Fri, 25 Oct 2019 14:49:48 +0200 Subject: [PATCH] run golangci-lint on travis --- .golangci.yml | 40 ++++++++++++++++++++++++++++++++++++++++ .travis.yml | 1 + entry.go | 2 +- travis/install.sh | 5 +++++ travis/lint.sh | 5 +++++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .golangci.yml create mode 100644 travis/lint.sh diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..65dc285 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,40 @@ +run: + # do not run on test files yet + tests: false + +# all available settings of specific linters +linters-settings: + errcheck: + # report about not checking of errors in type assetions: `a := b.(MyStruct)`; + # default is false: such cases aren't reported by default. + check-type-assertions: false + + # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; + # default is false: such cases aren't reported by default. + check-blank: false + + lll: + line-length: 100 + tab-width: 4 + + prealloc: + simple: false + range-loops: false + for-loops: false + + whitespace: + multi-if: false # Enforces newlines (or comments) after every multi-line if statement + multi-func: false # Enforces newlines (or comments) after every multi-line function signature + +linters: + enable: + - megacheck + - govet + disable: + - maligned + - prealloc + disable-all: false + presets: + - bugs + - unused + fast: false diff --git a/.travis.yml b/.travis.yml index 8bfc4f3..06918c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,7 @@ install: - ./travis/install.sh script: - ./travis/cross_build.sh + - ./travis/lint.sh - export GOMAXPROCS=4 - export GORACE=halt_on_error=1 - go test -race -v ./... diff --git a/entry.go b/entry.go index 7e2c899..f24cf8d 100644 --- a/entry.go +++ b/entry.go @@ -187,7 +187,7 @@ func getCaller() *runtime.Frame { // If the caller isn't part of this package, we're done if pkg != logrusPackage { - return &f + return &f //nolint:scopelint } } diff --git a/travis/install.sh b/travis/install.sh index 127ac8b..6fa9486 100755 --- a/travis/install.sh +++ b/travis/install.sh @@ -2,6 +2,11 @@ set -e +# Install golanci 1.21.0 +if [[ "$TRAVIS_GO_VERSION" =~ ^1\.13\. ]]; then + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.21.0 +fi + # Only do this for go1.12 when modules are on so that it doesn't need to be done when modules are off as well. if [[ "$TRAVIS_GO_VERSION" =~ ^1\.13\. ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$GO111MODULE" == "on" ]]; then GO111MODULE=off go get github.com/dgsb/gox diff --git a/travis/lint.sh b/travis/lint.sh new file mode 100644 index 0000000..0ed1d7c --- /dev/null +++ b/travis/lint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +if [[ "$TRAVIS_GO_VERSION" =~ ^1\.13\. ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$GO111MODULE" == "on" ]]; then + $(go env GOPATH)/bin/golangci-lint run ./... +fi