Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add golangci-lint, and fix linting issues #876

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions .circleci/config.yml
Expand Up @@ -8,6 +8,7 @@ references:
run:
name: "All Commands"
command: |
export GO111MODULE=on
mkdir -p bin
curl -Lso bin/shellcheck https://github.com/caarlos0/shellcheck-docker/releases/download/v0.4.6/shellcheck
chmod +x bin/shellcheck
Expand All @@ -21,7 +22,7 @@ references:
jobs:
go-current:
docker:
- image: circleci/golang:1.12
- image: circleci/golang:1.13
working_directory: *workspace
steps:
- checkout
Expand All @@ -31,7 +32,7 @@ jobs:
command: diff -u <(echo -n) <(gofmt -d -s .)
go-previous:
docker:
- image: circleci/golang:1.11
- image: circleci/golang:1.12
working_directory: *workspace
steps:
- checkout
Expand Down
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
* text=auto
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -37,3 +37,6 @@ cobra.test

.idea/
*.iml

# test-generated files
cobra/cmd/testproject
25 changes: 25 additions & 0 deletions .golangci.yml
@@ -0,0 +1,25 @@
run:
deadline: 5m

linters:
enable:
- deadcode
- errcheck
- gas
- goconst
- goimports
- golint
- govet
- ineffassign
- interfacer
- maligned
- megacheck
- structcheck
- unconvert
- varcheck
enable-all: false
disable-all: true
# presets:
# - bugs
# - unused
fast: false
27 changes: 12 additions & 15 deletions .travis.yml
@@ -1,28 +1,25 @@
language: go

stages:
- diff
- lint
- test

go:
- 1.10.x
- 1.11.x
- 1.12.x
- 1.13.x
- tip

matrix:
allow_failures:
- go: tip
include:
- stage: diff
go: 1.12.x
script: diff -u <(echo -n) <(gofmt -d -s .)

env: GO111MODULE=on
before_install: go get -u github.com/kyoh86/richgo

script:
- richgo test -v ./...
- go build
- if [ -z $NOVET ]; then
diff -u <(echo -n) <(go vet . 2>&1 | grep -vE 'ExampleCommand|bash_completions.*Fprint');
fi

matrix:
allow_failures:
- go: tip
include:
- stage: lint
go: 1.13.x
before_install: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin latest
script: golangci-lint run -v
4 changes: 1 addition & 3 deletions README.md
Expand Up @@ -215,7 +215,6 @@ package cmd
import (
"fmt"

homedir "github.com/mitchellh/go-homedir"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -261,7 +260,7 @@ func initConfig() {
viper.SetConfigFile(cfgFile)
} else {
// Find home directory.
home, err := homedir.Dir()
home, err := os.UserHomeDir()
if err != nil {
er(err)
}
Expand All @@ -270,7 +269,6 @@ func initConfig() {
viper.AddConfigPath(home)
viper.SetConfigName(".cobra")
}

viper.AutomaticEnv()

if err := viper.ReadInConfig(); err == nil {
Expand Down