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

chore: add non-empty .golangci.yml; fix whitespace lint issues #2244

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 19 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
---
run:
concurrency: 6
deadline: 5m
build-tags:
- btrfs_noversion
- libdm_no_deferred_remove
timeout: 5m

linters:
disable-all: true
enable:
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- unused
- whitespace

issues:
max-issues-per-linter: 0
max-same-issues: 0
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ validate: lint
@BUILDTAGS="$(BUILDTAGS)" hack/validate.sh

lint:
$(GOBIN)/golangci-lint run --build-tags "$(BUILDTAGS)"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also worry that moving the build tags to the config is going to get out of sync.

$(GOBIN)/golangci-lint run

# When this is running in CI, it will only check the CI commit range
.gitvalidation:
Expand Down
1 change: 0 additions & 1 deletion copy/progress_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,4 @@ func TestReadWithEvent(t *testing.T) {
read, err := reader.Read(b)
assert.Equal(t, read, 5)
assert.Nil(t, err)

}
1 change: 0 additions & 1 deletion docker/docker_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ func TestNewBearerTokenIssuedAtZeroFromJsonBlob(t *testing.T) {
if token.IssuedAt.Before(now) {
t.Fatalf("expected [%s] not to be before [%s]", token.IssuedAt, now)
}

}

func assertBearerTokensEqual(t *testing.T, expected, subject *bearerToken) {
Expand Down
1 change: 0 additions & 1 deletion docker/reference/regexp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,6 @@ func TestReferenceRegexp(t *testing.T) {
for i := range testcases {
checkRegexp(t, ReferenceRegexp, testcases[i])
}

}

func TestIdentifierRegexp(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/manifest/oci_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ func TestOCI1EditInstances(t *testing.T) {
require.NoError(t, err)
// Digest `ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff` should be re-ordered on update.
assert.Equal(t, list.Instances(), []digest.Digest{digest.Digest("sha256:e692418e4cbaf90ca69d05a66403747baa33ee08806650b51fab815ad7fc331f"), digest.Digest("sha256:5b0bcabd1ed22e9fb1310cf6c2dec7cdef19f0ad69efa1f392e94a4333501270"), digest.Digest("sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), digest.Digest("sha256:cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"), digest.Digest("sha256:ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), digest.Digest("sha256:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"), digest.Digest("sha256:hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh")})

}

func TestOCI1IndexChooseInstanceByCompression(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/signature/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ func FromBlob(blob []byte) (Signature, error) {
default:
return nil, fmt.Errorf("unrecognized signature format, starting with binary %#x", blob[0])
}

}

// UnsupportedFormatError returns an error complaining about sig having an unsupported format.
Expand Down
1 change: 0 additions & 1 deletion internal/signature/signature_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func TestBlobSimpleSigning(t *testing.T) {
fromBlobSimple, ok = fromBlob.(SimpleSigning)
require.True(t, ok)
assert.Equal(t, simpleSigData, fromBlobSimple.UntrustedSignature())

}

func TestBlobSigstore(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion internal/tmpdir/tmpdir_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ func TestCreateBigFileTemp(t *testing.T) {
sys.BigFilesTemporaryDir = "/tmp/bogus"
_, err = CreateBigFileTemp(&sys, "foobar1")
assert.Error(t, err)

}

func TestMkDirBigFileTemp(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/blobcache/blobcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func (b *BlobCache) findBlob(info types.BlobInfo) (string, int64, bool, error) {
}

return "", -1, false, nil

}

func (b *BlobCache) HasBlob(blobinfo types.BlobInfo) (bool, int64, error) {
Expand Down
2 changes: 0 additions & 2 deletions pkg/blobinfocache/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ func (sqc *cache) uncompressedDigest(tx *sql.Tx, anyDigest digest.Digest) (diges
return "", err
}
return d, nil

}
// A record as uncompressedDigest implies that anyDigest must already refer to an uncompressed digest.
// This way we don't have to waste storage space with trivial (uncompressed, uncompressed) mappings
Expand Down Expand Up @@ -561,7 +560,6 @@ func (sqc *cache) candidateLocations(transport types.ImageTransport, scope types
return []blobinfocache.BICReplacementCandidate2{} // FIXME? Log err (but throttle the log volume on repeated accesses)?
}
return prioritize.DestructivelyPrioritizeReplacementCandidates(res, primaryDigest, uncompressedDigest)

}

// CandidateLocations returns a prioritized, limited, number of blobs and their locations that could possibly be reused
Expand Down
1 change: 0 additions & 1 deletion pkg/docker/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ func modifyDockerConfigJSON(sys *types.SystemContext, editor func(fileContents *
if rawCH, ok := rawContents["credHelpers"]; ok {
if err := json.Unmarshal(rawCH, &syntheticContents.CredHelpers); err != nil {
return "", fmt.Errorf(`unmarshaling "credHelpers" in JSON at %q: %w`, path, err)

}
}

Expand Down
1 change: 0 additions & 1 deletion pkg/strslice/strslice_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func TestStrSliceUnmarshalJSON(t *testing.T) {
if !reflect.DeepEqual(actualParts, expectedParts) {
t.Fatalf("%#v: expected %v, got %v", json, expectedParts, actualParts)
}

}
}

Expand Down
1 change: 0 additions & 1 deletion pkg/sysregistriesv2/shortnames_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ func TestParseShortNameValue(t *testing.T) {
require.NoError(t, err)
assert.NotNil(t, named)
assert.Equal(t, "docker.io/library/fedora", named.String())

}

func TestValidateShortName(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/sysregistriesv2/system_registries_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,6 @@ func TestInvalidMirrorConfig(t *testing.T) {
_, err := GetRegistries(tc.sys)
assert.ErrorContains(t, err, tc.expectErr)
}

}

func TestTryUpdatingCache(t *testing.T) {
Expand Down
2 changes: 0 additions & 2 deletions signature/internal/rekor_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func VerifyRekorSET(publicKey *ecdsa.PublicKey, unverifiedRekorSET []byte, unver
}
if hashedRekordV001.Signature.PublicKey == nil {
return time.Time{}, NewInvalidSignatureError(`Missing "signature.publicKey" field in hashedrekord`)

}
rekorKeyOrCertPEM, rest := pem.Decode(hashedRekordV001.Signature.PublicKey.Content)
if rekorKeyOrCertPEM == nil {
Expand Down Expand Up @@ -228,7 +227,6 @@ func VerifyRekorSET(publicKey *ecdsa.PublicKey, unverifiedRekorSET []byte, unver
rekorPayloadHash, err := hex.DecodeString(*hashedRekordV001.Data.Hash.Value)
if err != nil {
return time.Time{}, NewInvalidSignatureError(fmt.Sprintf(`Invalid "data.hash.value" field in hashedrekord: %v`, err))

}
unverifiedPayloadHash := sha256.Sum256(unverifiedPayloadBytes)
if !bytes.Equal(rekorPayloadHash, unverifiedPayloadHash[:]) {
Expand Down
2 changes: 0 additions & 2 deletions signature/policy_eval_sigstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ func (pr *prSigstoreSigned) prepareTrustRoot() (*sigstoreSignedTrustRoot, error)
pkECDSA, ok := pk.(*ecdsa.PublicKey)
if !ok {
return nil, fmt.Errorf("Rekor public key is not using ECDSA")

}
res.rekorPublicKey = pkECDSA
}
Expand Down Expand Up @@ -154,7 +153,6 @@ func (pr *prSigstoreSigned) isSignatureAccepted(ctx context.Context, image priva
// Coverage: The key was loaded from a PEM format, so it’s unclear how this could fail.
// (PEM is not essential, MarshalPublicKeyToPEM can only fail if marshaling to ASN1.DER fails.)
return sarRejected, fmt.Errorf("re-marshaling public key to PEM: %w", err)

}
// We don’t care about the Rekor timestamp, just about log presence.
if _, err := internal.VerifyRekorSET(trustRoot.rekorPublicKey, []byte(untrustedSET), recreatedPublicKeyPEM, untrustedBase64Signature, untrustedPayload); err != nil {
Expand Down
1 change: 0 additions & 1 deletion signature/policy_eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ func TestPolicyContextRequirementsForImageRefNotRegisteredTransport(t *testing.T
reqs := pc.requirementsForImageRef(pcImageReferenceMock{transportName: "docker", ref: ref})
assert.True(t, &(reqs[0]) == &(pr[0]))
assert.True(t, len(reqs) == len(pr))

}

func TestPolicyContextRequirementsForImageRef(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion storage/storage_dest.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ func (f *zstdFetcher) GetBlobAt(chunks []chunked.ImageSourceChunk) (chan io.Read
err = chunked.ErrBadRequest{}
}
return rc, errs, err

}

// PutBlobPartial attempts to create a blob using the data that is already present
Expand Down