Skip to content

Commit

Permalink
Merge pull request #884 from vbatts/fix_lint
Browse files Browse the repository at this point in the history
*: switch to golangci-lint
  • Loading branch information
vbatts authored Dec 2, 2021
2 parents a5463b7 + d147780 commit a9fdc37
Show file tree
Hide file tree
Showing 12 changed files with 1,336 additions and 38 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/docs-and-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.15', '1.16', '1.17']
go: ['1.16', '1.17']

name: Documentation and Linting
steps:
Expand All @@ -30,8 +30,6 @@ jobs:
export PATH=$GOPATH/bin:$PATH
cd go/src/github.com/opencontainers/image-spec
make install.tools
go get -u github.com/alecthomas/gometalinter
gometalinter --install
go get -t -d ./...
ls ../
make
Expand Down
26 changes: 26 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
run:
timeout: 10m

linters:
disable-all: true
enable:
- deadcode
- dupl
- gofmt
- goimports
- gosimple
- govet
- ineffassign
- misspell
- nakedret
- revive
- structcheck
- unused
- varcheck
- staticcheck

linters-settings:
gofmt:
simplify: true
dupl:
threshold: 400
24 changes: 0 additions & 24 deletions .tool/lint

This file was deleted.

7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ check-license:
@echo "checking license headers"
@./.tool/check-license

lint:
lint: .install.lint
@echo "checking lint"
@./.tool/lint
@GO111MODULE=on golangci-lint run

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

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

.install.lint:
go get github.com/golangci/golangci-lint/cmd/golangci-lint@latest

.install.esc:
go get -u github.com/mjibson/esc

Expand Down
7 changes: 7 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@ module github.com/opencontainers/image-spec
go 1.11

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golangci/golangci-lint v1.43.0 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/opencontainers/go-digest v1.0.0
github.com/pkg/errors v0.9.1
github.com/russross/blackfriday v1.6.0
github.com/stretchr/testify v1.7.0 // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415
github.com/xeipuuv/gojsonschema v1.2.0
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
)
1,293 changes: 1,291 additions & 2 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion schema/backwards_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/opencontainers/go-digest"
"github.com/opencontainers/image-spec/schema"
"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

var compatMap = map[string]string{
Expand Down
4 changes: 2 additions & 2 deletions schema/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type fsLoader struct {
}

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

Expand Down Expand Up @@ -117,7 +117,7 @@ func decodeJSONUsingNumber(r io.Reader) (interface{}, error) {
}

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

Expand Down
2 changes: 1 addition & 1 deletion schema/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package schema
import (
"net/http"

"github.com/opencontainers/image-spec/specs-go/v1"
v1 "github.com/opencontainers/image-spec/specs-go/v1"
)

// Media types for the OCI image formats
Expand Down
1 change: 0 additions & 1 deletion schema/spec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ func validate(t *testing.T, name string) {
}

for _, err := range errs {
// TOOD(stevvooe): This is nearly useless without file, line no.
printFields(t, "invalid", example.Mediatype, example.Title)
t.Error(err)
fmt.Println(example.Body, "---")
Expand Down
2 changes: 1 addition & 1 deletion specs-go/v1/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "github.com/opencontainers/image-spec/specs-go"
type Index struct {
specs.Versioned

// MediaType specificies the type of this document data structure e.g. `application/vnd.oci.image.index.v1+json`
// MediaType specifies the type of this document data structure e.g. `application/vnd.oci.image.index.v1+json`
MediaType string `json:"mediaType,omitempty"`

// Manifests references platform specific manifests.
Expand Down
2 changes: 1 addition & 1 deletion specs-go/v1/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import "github.com/opencontainers/image-spec/specs-go"
type Manifest struct {
specs.Versioned

// MediaType specificies the type of this document data structure e.g. `application/vnd.oci.image.manifest.v1+json`
// MediaType specifies the type of this document data structure e.g. `application/vnd.oci.image.manifest.v1+json`
MediaType string `json:"mediaType,omitempty"`

// Config references a configuration object for a container, by digest.
Expand Down

0 comments on commit a9fdc37

Please sign in to comment.