Skip to content

Commit 6c3e3e5

Browse files
authored
chore: update linting scope (#1852)
Signed-off-by: Terry Howe <terrylhowe@gmail.com>
1 parent 0fbecc4 commit 6c3e3e5

File tree

14 files changed

+92
-22
lines changed

14 files changed

+92
-22
lines changed

.golangci.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Copyright The ORAS Authors.
2+
# Licensed under the Apache License, Version 2.0 (the "License");
3+
# you may not use this file except in compliance with the License.
4+
# You may obtain a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
14+
formatters:
15+
enable:
16+
- gofmt
17+
- goimports
18+
19+
exclusions:
20+
generated: lax
21+
22+
settings:
23+
gofmt:
24+
simplify: true
25+
26+
linters:
27+
default: standard
28+
29+
enable:
30+
- depguard
31+
- dupl
32+
- gomodguard
33+
- govet
34+
- ineffassign
35+
- misspell
36+
- staticcheck
37+
- thelper
38+
- unused
39+
- usestdlibvars
40+
- usetesting
41+
42+
exclusions:
43+
44+
generated: lax
45+
46+
presets:
47+
- comments
48+
- common-false-positives
49+
- legacy
50+
- std-error-handling
51+
52+
warn-unused: true
53+
54+
settings:
55+
depguard:
56+
rules:
57+
Main:
58+
deny:
59+
- pkg: github.com/hashicorp/go-multierror
60+
desc: "use errors instead"
61+
- pkg: github.com/pkg/errors
62+
desc: "use errors instead"
63+
64+
dupl:
65+
threshold: 400
66+
67+
run:
68+
timeout: 10m
69+
70+
version: "2"

cmd/oras/internal/display/metadata/descriptor/manifest_fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import (
1919
"encoding/json"
2020
"fmt"
2121
"io"
22-
"oras.land/oras/cmd/oras/internal/output"
2322

2423
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2524
"oras.land/oras/cmd/oras/internal/display/metadata"
25+
"oras.land/oras/cmd/oras/internal/output"
2626
)
2727

2828
// manifestFetchHandler handles metadata descriptor output.

cmd/oras/internal/display/metadata/text/tag_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ func TestNewTagHandler(t *testing.T) {
3535
}
3636

3737
handler := NewTagHandler(printer, target)
38-
3938
if handler == nil {
4039
t.Fatal("NewTagHandler should not return nil")
4140
}

cmd/oras/internal/display/status/console/console_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
)
2727

2828
func givenConsole(t *testing.T) (c Console, pty containerd.Console) {
29+
t.Helper()
2930
pty, _, err := containerd.NewPty()
3031
if err != nil {
3132
t.Fatal(err)
@@ -38,6 +39,7 @@ func givenConsole(t *testing.T) (c Console, pty containerd.Console) {
3839
}
3940

4041
func givenTestConsole(t *testing.T) (c Console, pty containerd.Console, tty *os.File) {
42+
t.Helper()
4143
var err error
4244
pty, tty, err = testutils.NewPty()
4345
if err != nil {

cmd/oras/internal/display/status/progress/status_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,7 @@ func Test_updateStatus(t *testing.T) {
363363
name: "updateStatusStartTime",
364364
update: updateStatusStartTime(),
365365
check: func(t *testing.T, s *status) {
366+
t.Helper()
366367
if s.startTime.IsZero() {
367368
t.Errorf("updateStatusStartTime() = %v, want non-zero", s.startTime)
368369
}
@@ -375,6 +376,7 @@ func Test_updateStatus(t *testing.T) {
375376
name: "updateStatusEndTime",
376377
update: updateStatusEndTime(),
377378
check: func(t *testing.T, s *status) {
379+
t.Helper()
378380
if s.endTime.IsZero() {
379381
t.Errorf("updateStatusEndTime() = %v, want non-zero", s.endTime)
380382
}
@@ -388,6 +390,7 @@ func Test_updateStatus(t *testing.T) {
388390
setup: updateStatusError(errTest),
389391
update: updateStatusEndTime(),
390392
check: func(t *testing.T, s *status) {
393+
t.Helper()
391394
if s.endTime.IsZero() {
392395
t.Errorf("updateStatusEndTime() = %v, want non-zero", s.endTime)
393396
}

cmd/oras/internal/display/status/text_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func TestMain(m *testing.M) {
4646
}
4747

4848
func validatePrinted(t *testing.T, expected string) {
49+
t.Helper()
4950
actual := strings.TrimSpace(builder.String())
5051
if expected != actual {
5152
t.Error("Output does not match expected <" + expected + "> actual <" + actual + ">")

cmd/oras/internal/option/packer_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ func TestPacker_parseAnnotations_annotationFlag(t *testing.T) {
154154
}
155155

156156
func givenTestFile(t *testing.T, data string) (path string) {
157+
t.Helper()
157158
tempDir := t.TempDir()
158159
fileName := "test.txt"
159160
path = filepath.Join(tempDir, fileName)

cmd/oras/root/cp_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,8 @@ func Test_prepareCopyOption_referrersFailureOnIndex(t *testing.T) {
335335
if desc.MediaType == ocispec.MediaTypeImageIndex {
336336
return nil, errMockedReferrers
337337
}
338-
return []ocispec.Descriptor{ocispec.Descriptor{}}, nil
338+
entry := ocispec.Descriptor{}
339+
return []ocispec.Descriptor{entry}, nil
339340
},
340341
}
341342

cmd/oras/root/manifest/fetch_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
func Test_fetchManifest_errType(t *testing.T) {
28-
// prepare
28+
// prepare
2929
cmd := &cobra.Command{}
3030
cmd.SetContext(context.Background())
3131

cmd/oras/root/manifest/index/create_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ func Test_enrichDescriptor(t *testing.T) {
165165
`),
166166
manifestMediaType: "application/vnd.oci.image.index.v1+json",
167167
checkDesc: func(t *testing.T, gotDesc, inputDesc ocispec.Descriptor) {
168+
t.Helper()
168169
if got, want := gotDesc.ArtifactType, "application/vnd.example"; got != want {
169170
t.Errorf("ArtifactType = %s, want %s", got, want)
170171
}
@@ -192,6 +193,7 @@ func Test_enrichDescriptor(t *testing.T) {
192193
`),
193194
manifestMediaType: "application/vnd.oci.image.manifest.v1+json",
194195
checkDesc: func(t *testing.T, gotDesc, inputDesc ocispec.Descriptor) {
196+
t.Helper()
195197
if got, want := gotDesc.ArtifactType, "application/vnd.example"; got != want {
196198
t.Errorf("ArtifactType = %s, want %s", got, want)
197199
}
@@ -226,6 +228,7 @@ func Test_enrichDescriptor(t *testing.T) {
226228
`),
227229
manifestMediaType: "application/vnd.oci.image.manifest.v1+json",
228230
checkDesc: func(t *testing.T, gotDesc, inputDesc ocispec.Descriptor) {
231+
t.Helper()
229232
if got, want := gotDesc.ArtifactType, "application/vnd.example"; got != want {
230233
t.Errorf("ArtifactType = %s, want %s", got, want)
231234
}
@@ -241,6 +244,7 @@ func Test_enrichDescriptor(t *testing.T) {
241244
manifestBytes: []byte(`{}`),
242245
manifestMediaType: "application/vnd.custom",
243246
checkDesc: func(t *testing.T, gotDesc, inputDesc ocispec.Descriptor) {
247+
t.Helper()
244248
if !reflect.DeepEqual(gotDesc, inputDesc) {
245249
t.Errorf("result does not match input: got %#v, want %#v", gotDesc, inputDesc)
246250
}

0 commit comments

Comments
 (0)