Skip to content

Commit

Permalink
Merge pull request #60 from minamijoyo/use-golangci-instead-of-golint
Browse files Browse the repository at this point in the history
Use golangci instead of golint
  • Loading branch information
minamijoyo authored Jan 13, 2022
2 parents f7a972c + 48b2a61 commit 5bd5635
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 34 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: lint
permissions:
contents: read
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.43.0
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
restore-keys: |
${{ runner.os }}-go-
- name: test
run: make check
run: make test
12 changes: 12 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# https://golangci-lint.run/usage/configuration/
linters:
disable-all: true
enable:
- errcheck
- goimports
- gosec
- gosimple
- govet
- ineffassign
- revive
- staticcheck
20 changes: 4 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
NAME := tfupdate

ifndef GOBIN
GOBIN := $(shell echo "$${GOPATH%%:*}/bin")
endif

GOLINT := $(GOBIN)/golint

$(GOLINT): ; @go install golang.org/x/lint/golint

.DEFAULT_GOAL := build

.PHONY: deps
Expand All @@ -23,16 +15,12 @@ install: deps
go install

.PHONY: lint
lint: $(GOLINT)
golint $$(go list ./... | grep -v /vendor/)

.PHONY: vet
vet:
go vet ./...
lint:
golangci-lint run ./...

.PHONY: test
test: deps
test: build
go test ./...

.PHONY: check
check: lint vet test build
check: lint test
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ require (
github.com/spf13/pflag v1.0.5
github.com/xanzy/go-gitlab v0.20.1
github.com/zclconf/go-cty v1.8.0
golang.org/x/lint v0.0.0-20190930215403-16217165b5de
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6
)

Expand All @@ -38,7 +37,6 @@ require (
golang.org/x/net v0.0.0-20200301022130-244492dfa37a // indirect
golang.org/x/sys v0.0.0-20190502175342-a43fa875dd82 // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/tools v0.0.0-20190311212946-11955173bddd // indirect
google.golang.org/appengine v1.6.5 // indirect
)

Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ github.com/zclconf/go-cty-debug v0.0.0-20191215020915-b22d67c1ba0b/go.mod h1:ZRK
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734 h1:p/H982KKEjUnLJkM3tt/LemDnOc1GiZL5FCVlORJ5zo=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180811021610-c39426892332/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20181108082009-03003ca0c849/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -113,8 +111,6 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.5 h1:i6eZZ+zk0SOf0xgBpEpPD18qWcJda6q1sxt3S0kzyUQ=
golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd h1:/e+gpKk9r3dJobndpTytxS2gOy6m5uvpg+ISQoEcusQ=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
Expand Down
2 changes: 1 addition & 1 deletion release/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func NewGitLabClient(config GitLabConfig) (*GitLabClient, error) {
if err != nil {
return nil, fmt.Errorf("failed to parse gitlab base url: %s", err)
}
c.SetBaseURL(baseURL.String())
c.SetBaseURL(baseURL.String()) // nolint: errcheck
}

return &GitLabClient{
Expand Down
2 changes: 1 addition & 1 deletion tfupdate/hclwrite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ service "label1" {
}

for _, test := range tests {
t.Run(fmt.Sprintf("%s", test.typeName), func(t *testing.T) {
t.Run(fmt.Sprintf("%s", test.typeName), func(t *testing.T) { // nolint: gosimple
f, diags := hclwrite.ParseConfig([]byte(test.src), "", hcl.Pos{Line: 1, Column: 1})
if len(diags) != 0 {
for _, diag := range diags {
Expand Down
2 changes: 1 addition & 1 deletion tfupdate/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func UpdateHCL(r io.Reader, w io.Writer, filename string, o Option) (bool, error
return false, err
}

u.Update(f)
u.Update(f) // nolint: errcheck
output := f.BuildTokens(nil).Bytes()

if _, err := w.Write(output); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion tfupdate/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ provider "aws" {
t.Errorf("UpdateHCL() with src = %s, o = %#v expects to return isUpdated = %t, but want = %t", tc.src, tc.o, isUpdated, tc.isUpdated)
}

got := string(w.Bytes())
got := string(w.Bytes()) // nolint: gosimple
if got != tc.want {
t.Errorf("UpdateHCL() with src = %s, o = %#v returns %s, but want = %s", tc.src, tc.o, got, tc.want)
}
Expand Down
7 changes: 0 additions & 7 deletions tools.go

This file was deleted.

0 comments on commit 5bd5635

Please sign in to comment.