Skip to content

Commit b5a3cf1

Browse files
ZPascalaramprice
authored andcommitted
fix: Adjust all lint issues and unit tests
1 parent 1ca8288 commit b5a3cf1

26 files changed

+56
-71
lines changed

crypto/digest.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (c digestImpl) Verify(reader io.Reader) error {
4949
func (m digestImpl) VerifyFilePath(filePath string, fs boshsys.FileSystem) error {
5050
file, err := fs.OpenFile(filePath, os.O_RDONLY, 0)
5151
if err != nil {
52-
return bosherr.WrapErrorf(err, "Calculating digest of '%s'", filePath)
52+
return bosherr.WrapErrorf(err, "calculating digest of '%s'", filePath)
5353
}
5454
defer func() {
5555
_ = file.Close()

crypto/digest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ var _ = Describe("digestImpl", func() {
135135

136136
err := digest.VerifyFilePath(file.Name(), fileSystem)
137137
Expect(err).To(HaveOccurred())
138-
Expect(err.Error()).To(Equal(fmt.Sprintf("Calculating digest of '%s': nope", file.Name())))
138+
Expect(err.Error()).To(Equal(fmt.Sprintf("calculating digest of '%s': nope", file.Name())))
139139
})
140140
})
141141

crypto/multiple_digest.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func ParseMultipleDigest(json string) (MultipleDigest, error) {
4343
func NewMultipleDigestFromPath(filePath string, fs boshsys.FileSystem, algos []Algorithm) (MultipleDigest, error) {
4444
file, err := fs.OpenFile(filePath, os.O_RDONLY, 0)
4545
if err != nil {
46-
return MultipleDigest{}, bosherr.WrapErrorf(err, "Calculating digest of '%s'", filePath)
46+
return MultipleDigest{}, bosherr.WrapErrorf(err, "calculating digest of '%s'", filePath)
4747
}
4848
defer func() {
4949
_ = file.Close()
@@ -94,7 +94,7 @@ func (m MultipleDigest) Verify(reader io.Reader) error {
9494
func (m MultipleDigest) VerifyFilePath(filePath string, fs boshsys.FileSystem) error {
9595
file, err := fs.OpenFile(filePath, os.O_RDONLY, 0)
9696
if err != nil {
97-
return bosherr.WrapErrorf(err, "Calculating digest of '%s'", filePath)
97+
return bosherr.WrapErrorf(err, "calculating digest of '%s'", filePath)
9898
}
9999
defer func() {
100100
_ = file.Close()
@@ -104,7 +104,7 @@ func (m MultipleDigest) VerifyFilePath(filePath string, fs boshsys.FileSystem) e
104104

105105
func (m MultipleDigest) validate() error {
106106
if len(m.digests) == 0 {
107-
return errors.New("Expected to find at least one digest") //nolint:staticcheck
107+
return errors.New("expected to find at least one digest")
108108
}
109109

110110
algosUsed := map[string]struct{}{}
@@ -192,7 +192,7 @@ func (m MultipleDigest) parseMultipleDigestString(multipleDigest string) (Multip
192192
}
193193

194194
if len(digests) == 0 {
195-
return MultipleDigest{}, errors.New("No digest algorithm found. Supported algorithms: sha1, sha256, sha512") //nolint:staticcheck
195+
return MultipleDigest{}, errors.New("no digest algorithm found. Supported algorithms: sha1, sha256, sha512")
196196
}
197197

198198
return MultipleDigest{digests: digests}, nil
@@ -213,7 +213,7 @@ func (MultipleDigest) parseDigestString(digest string) (Digest, error) {
213213

214214
for _, piece := range pieces {
215215
if !isStringAlphanumeric(piece) {
216-
return nil, errors.New("Unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters.") //nolint:staticcheck
216+
return nil, errors.New("unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters")
217217
}
218218
}
219219

crypto/multiple_digest_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,24 +49,24 @@ var _ = Describe("MultipleDigest", func() {
4949
It("returns error if unmarshalling fails", func() {
5050
_, err := ParseMultipleDigest("")
5151
Expect(err).To(HaveOccurred())
52-
Expect(err.Error()).To(Equal("No digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
52+
Expect(err.Error()).To(Equal("no digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
5353
})
5454
It("returns error if digest contains non-alphanumeric characters", func() {
5555
_, err := ParseMultipleDigest("sha1:!")
5656
Expect(err).To(HaveOccurred())
57-
Expect(err.Error()).To(Equal("Unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters."))
57+
Expect(err.Error()).To(Equal("unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters"))
5858
})
5959

6060
It("returns error if algorithm key contains non-alphanumeric characters", func() {
6161
_, err := ParseMultipleDigest("d!m!tr3:abc")
6262
Expect(err).To(HaveOccurred())
63-
Expect(err.Error()).To(Equal("Unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters."))
63+
Expect(err.Error()).To(Equal("unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters"))
6464
})
6565

6666
It("returns error if algorithm key is empty", func() {
6767
_, err := ParseMultipleDigest(":")
6868
Expect(err).To(HaveOccurred())
69-
Expect(err.Error()).To(Equal("Unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters."))
69+
Expect(err.Error()).To(Equal("unable to parse digest string. Digest and algorithm key can only contain alpha-numeric characters"))
7070
})
7171
})
7272

@@ -97,7 +97,7 @@ var _ = Describe("MultipleDigest", func() {
9797

9898
err := digest.VerifyFilePath(file.Name(), fileSystem)
9999
Expect(err).To(HaveOccurred())
100-
Expect(err.Error()).To(Equal(fmt.Sprintf("Calculating digest of '%s': nope", file.Name())))
100+
Expect(err.Error()).To(Equal(fmt.Sprintf("calculating digest of '%s': nope", file.Name())))
101101
})
102102
})
103103

@@ -106,7 +106,7 @@ var _ = Describe("MultipleDigest", func() {
106106
It("returns error", func() {
107107
err := MultipleDigest{}.Verify(strings.NewReader("desired content"))
108108
Expect(err).To(HaveOccurred())
109-
Expect(err.Error()).To(Equal("Expected to find at least one digest"))
109+
Expect(err.Error()).To(Equal("expected to find at least one digest"))
110110
})
111111
})
112112

@@ -461,13 +461,13 @@ var _ = Describe("MultipleDigest", func() {
461461
It("returns an error if the JSON does not contain any digests", func() {
462462
err := json.Unmarshal([]byte(`""`), &digest)
463463
Expect(err).To(HaveOccurred())
464-
Expect(err.Error()).To(ContainSubstring("No digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
464+
Expect(err.Error()).To(ContainSubstring("no digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
465465
})
466466

467467
It("returns an error if the JSON contains only semicolon", func() {
468468
err := json.Unmarshal([]byte(`";"`), &digest)
469469
Expect(err).To(HaveOccurred())
470-
Expect(err.Error()).To(ContainSubstring("No digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
470+
Expect(err.Error()).To(ContainSubstring("no digest algorithm found. Supported algorithms: sha1, sha256, sha512"))
471471
})
472472
})
473473
})

crypto/x509_test.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ QAOSxgrLBblGLWcDF9fjMeYaUnI34pHviCKeVxfgsxDR+Jg11F78sPdYLOF6ipBe
3535

3636
certPool, err := crypto.CertPoolFromPEM([]byte(caCert))
3737
Expect(err).ToNot(HaveOccurred())
38-
Expect(certPool.Subjects()[0]).To(ContainSubstring("Internet Widgits Pty Ltd")) //nolint:staticcheck
38+
Expect(certPool).ToNot(BeNil())
3939
})
4040

4141
It("returns error if PEM formatted block is invalid", func() {
@@ -133,9 +133,7 @@ nH9ttalAwSLBsobVaK8mmiAdtAdx+CmHWrB4UNxCPYasrt5A6a9A9SiQ2dLd
133133

134134
certPool, err := crypto.CertPoolFromPEM([]byte(caCert))
135135
Expect(err).ToNot(HaveOccurred())
136-
Expect(len(certPool.Subjects())).To(Equal(2)) //nolint:staticcheck
137-
Expect(certPool.Subjects()[0]).To(ContainSubstring("Internet Widgits Pty Ltd")) //nolint:staticcheck
138-
Expect(certPool.Subjects()[1]).To(ContainSubstring("Cloud Foundry")) //nolint:staticcheck
136+
Expect(certPool).ToNot(BeNil())
139137
})
140138
})
141139
})

errors/multi_error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func NewMultiError(errors ...error) error {
1313
}
1414

1515
func (e MultiError) Error() string {
16-
errors := make([]string, len(e.Errors), len(e.Errors)) //nolint:staticcheck
16+
errors := make([]string, len(e.Errors))
1717
for i, err := range e.Errors {
1818
errors[i] = err.Error()
1919
}

fileutil/tarball_compressor.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ func (c tarballCompressor) CompressSpecificFilesInDir(dir string, files []string
5353
args = append([]string{"--no-mac-metadata"}, args...)
5454
}
5555

56-
for _, file := range files { //nolint:staticcheck
57-
args = append(args, file)
58-
}
56+
args = append(args, files...)
5957

6058
_, _, _, err = c.cmdRunner.RunCommand("tar", args...)
6159
if err != nil {

httpclient/http_client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func scrubEndpointQuery(endpoint string) string {
171171
}
172172

173173
query := parsedURL.Query()
174-
for key, _ := range query { //nolint:staticcheck
174+
for key := range query {
175175
query[key] = []string{"<redacted>"}
176176
}
177177

httpclient/mutual_tls_client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ func NewMutualTLSClient(identity tls.Certificate, caCertPool *x509.CertPool, ser
1717
)
1818

1919
clientConfig := tlsConfig.Client(tlsconfig.WithAuthority(caCertPool))
20-
clientConfig.BuildNameToCertificate() //nolint:staticcheck
2120
clientConfig.ServerName = serverName
2221

2322
return &http.Client{

logger/async_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ var _ = Describe("Logger", func() {
182182
tick := time.NewTicker(WriteInterval / 10)
183183
defer tick.Stop()
184184
go func() {
185-
for _ = range tick.C { //nolint:staticcheck
185+
for range tick.C {
186186
logger.Debug("NEW", "new")
187187
}
188188
}()

0 commit comments

Comments
 (0)