Skip to content

Commit a9fdc37

Browse files
authored
Merge pull request #884 from vbatts/fix_lint
*: switch to golangci-lint
2 parents a5463b7 + d147780 commit a9fdc37

File tree

12 files changed

+1336
-38
lines changed

12 files changed

+1336
-38
lines changed

.github/workflows/docs-and-linting.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
go: ['1.15', '1.16', '1.17']
12+
go: ['1.16', '1.17']
1313

1414
name: Documentation and Linting
1515
steps:
@@ -30,8 +30,6 @@ jobs:
3030
export PATH=$GOPATH/bin:$PATH
3131
cd go/src/github.com/opencontainers/image-spec
3232
make install.tools
33-
go get -u github.com/alecthomas/gometalinter
34-
gometalinter --install
3533
go get -t -d ./...
3634
ls ../
3735
make

.golangci.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
run:
2+
timeout: 10m
3+
4+
linters:
5+
disable-all: true
6+
enable:
7+
- deadcode
8+
- dupl
9+
- gofmt
10+
- goimports
11+
- gosimple
12+
- govet
13+
- ineffassign
14+
- misspell
15+
- nakedret
16+
- revive
17+
- structcheck
18+
- unused
19+
- varcheck
20+
- staticcheck
21+
22+
linters-settings:
23+
gofmt:
24+
simplify: true
25+
dupl:
26+
threshold: 400

.tool/lint

Lines changed: 0 additions & 24 deletions
This file was deleted.

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ check-license:
9292
@echo "checking license headers"
9393
@./.tool/check-license
9494

95-
lint:
95+
lint: .install.lint
9696
@echo "checking lint"
97-
@./.tool/lint
97+
@GO111MODULE=on golangci-lint run
9898

9999
test: schema/fs.go
100100
go test -race -cover $(shell go list ./... | grep -v /vendor/)
@@ -114,6 +114,9 @@ endif
114114

115115
install.tools: $(TOOLS:%=.install.%)
116116

117+
.install.lint:
118+
go get github.com/golangci/golangci-lint/cmd/golangci-lint@latest
119+
117120
.install.esc:
118121
go get -u github.com/mjibson/esc
119122

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,16 @@ module github.com/opencontainers/image-spec
33
go 1.11
44

55
require (
6+
github.com/davecgh/go-spew v1.1.1 // indirect
7+
github.com/golangci/golangci-lint v1.43.0 // indirect
8+
github.com/kr/text v0.2.0 // indirect
9+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
610
github.com/opencontainers/go-digest v1.0.0
711
github.com/pkg/errors v0.9.1
812
github.com/russross/blackfriday v1.6.0
13+
github.com/stretchr/testify v1.7.0 // indirect
914
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
1015
github.com/xeipuuv/gojsonschema v1.2.0
16+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
17+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
1118
)

go.sum

Lines changed: 1291 additions & 2 deletions
Large diffs are not rendered by default.

schema/backwards_compatibility_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121

2222
"github.com/opencontainers/go-digest"
2323
"github.com/opencontainers/image-spec/schema"
24-
"github.com/opencontainers/image-spec/specs-go/v1"
24+
v1 "github.com/opencontainers/image-spec/specs-go/v1"
2525
)
2626

2727
var compatMap = map[string]string{

schema/loader.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ type fsLoader struct {
7878
}
7979

8080
// JsonSource implements gojsonschema.JSONLoader.JsonSource. The "Json" capitalization needs to be maintained to conform to the interface.
81-
func (l *fsLoader) JsonSource() interface{} { // nolint: golint
81+
func (l *fsLoader) JsonSource() interface{} { // revive:disable-line:var-naming
8282
return l.source
8383
}
8484

@@ -117,7 +117,7 @@ func decodeJSONUsingNumber(r io.Reader) (interface{}, error) {
117117
}
118118

119119
// JsonReference implements gojsonschema.JSONLoader.JsonReference. The "Json" capitalization needs to be maintained to conform to the interface.
120-
func (l *fsLoader) JsonReference() (gojsonreference.JsonReference, error) { // nolint: golint
120+
func (l *fsLoader) JsonReference() (gojsonreference.JsonReference, error) { // revive:disable-line:var-naming
121121
return gojsonreference.NewJsonReference(l.JsonSource().(string))
122122
}
123123

schema/schema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ package schema
1717
import (
1818
"net/http"
1919

20-
"github.com/opencontainers/image-spec/specs-go/v1"
20+
v1 "github.com/opencontainers/image-spec/specs-go/v1"
2121
)
2222

2323
// Media types for the OCI image formats

schema/spec_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ func validate(t *testing.T, name string) {
9595
}
9696

9797
for _, err := range errs {
98-
// TOOD(stevvooe): This is nearly useless without file, line no.
9998
printFields(t, "invalid", example.Mediatype, example.Title)
10099
t.Error(err)
101100
fmt.Println(example.Body, "---")

0 commit comments

Comments
 (0)