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

*: switch to golangci-lint #884

Merged
merged 3 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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