Skip to content

Commit 8e54714

Browse files
authored
Update linter version and migrated configuration (#497)
## Fixes <!-- List the issue(s) this PR resolves --> - ## Changes <!-- List the changes this PR introduces --> - ## Checklist <!-- Put an `x` in the boxes. All tasks must be completed and boxes checked before merging. --> - [ ] 🤖 This change is covered by unit tests (if applicable). - [ ] 🤹 Manual testing has been performed (if necessary). - [ ] 🛡️ Security impacts have been considered (if relevant). - [ ] 📖 Documentation updates are complete (if required). - [ ] 🧠 Third-party dependencies and TPIP updated (if required).
1 parent 8ee1d7c commit 8e54714

File tree

10 files changed

+41
-38
lines changed

10 files changed

+41
-38
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
go-version-file: go.mod
4242
check-latest: true
4343

44-
- uses: golangci/golangci-lint-action@4696ba8babb6127d732c3c6dde519db15edab9ea # v6.5.1
44+
- uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
4545
with:
4646
version: latest
4747

.golangci.yml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1+
version: "2"
12
run:
2-
timeout: 10m
3-
4-
# Run linters over integration tests
53
build-tags:
64
- integration
7-
85
linters:
9-
disable-all: true # Disable defaults, then enable the ones we want
6+
default: none
107
enable:
118
- errcheck
12-
- gosimple
9+
- gosec
1310
- govet
1411
- ineffassign
1512
- staticcheck
16-
# - structcheck https://github.com/golangci/golangci-lint/issues/2649
17-
- typecheck
1813
- unused
19-
# - bodyclose Disabled so concurrent GETs can happen
20-
- stylecheck
21-
- gosec
14+
settings:
15+
staticcheck:
16+
checks:
17+
- -SA1019
18+
- all
19+
exclusions:
20+
generated: lax
21+
presets:
22+
- comments
23+
- common-false-positives
24+
- legacy
25+
- std-error-handling
26+
formatters:
27+
enable:
28+
- gofmt
2229
- goimports
23-
- gci
24-
25-
linters-settings:
26-
staticcheck:
27-
checks:
28-
- all
29-
- "-SA1019" # Disable "rand.Seed has been deprecated"

cmd/cryptography/checksum.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func GenerateChecksum(sourcePack, destinationDir, hashFunction string) error {
6262
}
6363
base = filepath.Clean(destinationDir) + string(filepath.Separator) + strings.TrimSuffix(string(filepath.Base(sourcePack)), ".pack")
6464
}
65-
checksumFilename := base + "." + strings.Replace(hashFunction, "-", "", -1) + ".checksum"
65+
checksumFilename := base + "." + strings.ReplaceAll(hashFunction, "-", "") + ".checksum"
6666
if utils.FileExists(checksumFilename) {
6767
log.Errorf("\"%s\" already exists, choose a diferent path", checksumFilename)
6868
return errs.ErrPathAlreadyExists

cmd/installer/pack.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,11 +453,11 @@ func (p *PackType) uninstall(installation *PacksInstallationType) error {
453453
func (p *PackType) readEula() ([]byte, error) {
454454
log.Debug("Reading EULA")
455455

456-
licenseFileName := strings.Replace(p.Pdsc.License, "\\", "/", -1)
456+
licenseFileName := strings.ReplaceAll(p.Pdsc.License, "\\", "/")
457457

458458
// License contains the license path inside the pack file
459459
for _, file := range p.zipReader.File {
460-
possibleLicense := strings.Replace(file.Name, "\\", "/", -1)
460+
possibleLicense := strings.ReplaceAll(file.Name, "\\", "/")
461461
if possibleLicense == licenseFileName {
462462

463463
reader, _ := file.Open()

cmd/installer/root.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -915,12 +915,12 @@ func findInstalledPacks(addLocalPacks, removeDuplicates bool) ([]installedPack,
915915
return nil, err
916916
}
917917
for _, match := range matches {
918-
pdscPath := strings.Replace(match, Installation.PackRoot, "", -1)
918+
pdscPath := strings.ReplaceAll(match, Installation.PackRoot, "")
919919
packName, _ := filepath.Split(pdscPath)
920-
packName = strings.Replace(packName, "/", " ", -1)
921-
packName = strings.Replace(packName, "\\", " ", -1)
920+
packName = strings.ReplaceAll(packName, "/", " ")
921+
packName = strings.ReplaceAll(packName, "\\", " ")
922922
packName = strings.Trim(packName, " ")
923-
packName = strings.Replace(packName, " ", ".", -1)
923+
packName = strings.ReplaceAll(packName, " ", ".")
924924

925925
packNameBits := strings.SplitN(packName, ".", 3)
926926

@@ -978,6 +978,7 @@ func findInstalledPacks(addLocalPacks, removeDuplicates bool) ([]installedPack,
978978
noDupInstalledPacks = append(noDupInstalledPacks, installedPacks[0])
979979
for i, installedPack := range installedPacks {
980980
if i > 0 {
981+
//nolint:staticcheck // intentional logic for clarity
981982
if !(installedPacks[last].Vendor == installedPack.Vendor && installedPacks[last].Name == installedPack.Name) {
982983
noDupInstalledPacks = append(noDupInstalledPacks, installedPack)
983984
last = i

cmd/installer/root_pack_list_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func ExampleListInstalledPacks_list() {
8787
_ = installer.ReadIndexFiles()
8888
defer removePackRoot(localTestingDir)
8989

90-
pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1)
90+
pdscFilePath := strings.ReplaceAll(publicLocalPack123, ".1.2.3.pack", ".pdsc")
9191
_ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc"))
9292
_ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{
9393
Vendor: "TheVendor",
@@ -125,7 +125,7 @@ func ExampleListInstalledPacks_listCached() {
125125
_ = installer.ReadIndexFiles()
126126
defer removePackRoot(localTestingDir)
127127

128-
pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1)
128+
pdscFilePath := strings.ReplaceAll(publicLocalPack123, ".1.2.3.pack", ".pdsc")
129129
_ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc"))
130130
_ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{
131131
Vendor: "TheVendor",
@@ -165,7 +165,7 @@ func TestListInstalledPacks(t *testing.T) {
165165
assert.Nil(installer.ReadIndexFiles())
166166
defer removePackRoot(localTestingDir)
167167

168-
pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1)
168+
pdscFilePath := strings.ReplaceAll(publicLocalPack123, ".1.2.3.pack", ".pdsc")
169169
assert.Nil(utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc")))
170170
assert.Nil(installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{
171171
Vendor: "TheVendor",
@@ -251,7 +251,7 @@ func ExampleListInstalledPacks_listMalformedInstalledPacks() {
251251
_ = installer.ReadIndexFiles()
252252
defer removePackRoot(localTestingDir)
253253

254-
pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1)
254+
pdscFilePath := strings.ReplaceAll(publicLocalPack123, ".1.2.3.pack", ".pdsc")
255255
_ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc"))
256256
_ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{
257257
Vendor: "TheVendor",
@@ -290,7 +290,7 @@ func ExampleListInstalledPacks_filter() {
290290
_ = installer.ReadIndexFiles()
291291
defer removePackRoot(localTestingDir)
292292

293-
pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1)
293+
pdscFilePath := strings.ReplaceAll(publicLocalPack123, ".1.2.3.pack", ".pdsc")
294294
_ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc"))
295295
_ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{
296296
Vendor: "TheVendor",
@@ -326,7 +326,7 @@ func ExampleListInstalledPacks_filterErrorPackages() {
326326
_ = installer.ReadIndexFiles()
327327
defer removePackRoot(localTestingDir)
328328

329-
pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1)
329+
pdscFilePath := strings.ReplaceAll(publicLocalPack123, ".1.2.3.pack", ".pdsc")
330330
_ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc"))
331331
_ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{
332332
Vendor: "TheVendor",
@@ -364,7 +364,7 @@ func ExampleListInstalledPacks_filterInvalidChars() {
364364
_ = installer.ReadIndexFiles()
365365
defer removePackRoot(localTestingDir)
366366

367-
pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1)
367+
pdscFilePath := strings.ReplaceAll(publicLocalPack123, ".1.2.3.pack", ".pdsc")
368368
_ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc"))
369369
_ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{
370370
Vendor: "TheVendor",
@@ -399,7 +399,7 @@ func ExampleListInstalledPacks_filteradditionalMessages() {
399399
_ = installer.ReadIndexFiles()
400400
defer removePackRoot(localTestingDir)
401401

402-
pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1)
402+
pdscFilePath := strings.ReplaceAll(publicLocalPack123, ".1.2.3.pack", ".pdsc")
403403
_ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc"))
404404
_ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{
405405
Vendor: "TheVendor",

cmd/installer/root_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ func TestUpdatePublicIndex(t *testing.T) {
488488
assert.Nil(err)
489489
indexServer := NewServer()
490490
// The psd URL needs to be updated as it's not known beforehand
491-
updatedIndex := []byte(strings.Replace(string(indexContent), "https://127.0.0.1", indexServer.URL(), -1))
491+
updatedIndex := []byte(strings.ReplaceAll(string(indexContent), "https://127.0.0.1", indexServer.URL()))
492492
indexServer.AddRoute(installer.PublicIndex, updatedIndex)
493493
indexPath := indexServer.URL() + installer.PublicIndex
494494

@@ -619,7 +619,7 @@ func TestUpdatePublicIndex(t *testing.T) {
619619
assert.Nil(err)
620620
indexServer := NewServer()
621621
// The psd URL needs to be updated as it's not known beforehand
622-
updatedIndex := []byte(strings.Replace(string(indexContent), "https://127.0.0.1", indexServer.URL(), -1))
622+
updatedIndex := []byte(strings.ReplaceAll(string(indexContent), "https://127.0.0.1", indexServer.URL()))
623623
indexServer.AddRoute(installer.PublicIndex, updatedIndex)
624624
indexPath := indexServer.URL() + installer.PublicIndex
625625

@@ -650,7 +650,7 @@ func TestUpdatePublicIndex(t *testing.T) {
650650
assert.Nil(err)
651651
indexServer := NewServer()
652652
// The psd URL needs to be updated as it's not known beforehand
653-
updatedIndex := []byte(strings.Replace(string(indexContent), "https://127.0.0.1", indexServer.URL(), -1))
653+
updatedIndex := []byte(strings.ReplaceAll(string(indexContent), "https://127.0.0.1", indexServer.URL()))
654654
indexServer.AddRoute(installer.PublicIndex, updatedIndex)
655655
indexPath := indexServer.URL() + installer.PublicIndex
656656

cmd/ui/eula.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func NewLicenseWindow(licenseTitle, licenseContents, promptText string) *License
121121
}
122122
v.Wrap = true
123123
v.Title = licenseTitle
124-
fmt.Fprint(v, strings.Replace(licenseContents, "\r", "", -1))
124+
fmt.Fprint(v, strings.ReplaceAll(licenseContents, "\r", ""))
125125
}
126126

127127
// Prompt window dimensions

cmd/utils/packs.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ func ExtractPackInfo(packPath string) (PackInfo, error) {
222222
// location can be either a URL or a path to the local
223223
// file system. If it's the latter, make sure to fill in
224224
// in case the file is coming from the current directory
225+
//nolint:staticcheck // intentional logic for clarity
225226
if !(strings.HasPrefix(location, "http://") || strings.HasPrefix(location, "https://") || strings.HasPrefix(location, "file://")) {
226227
if !filepath.IsAbs(location) {
227228
if len(filepath.VolumeName(location)) == 0 && len(location) > 0 && (location[0] == '/' || location[0] == '\\') {

cmd/utils/utils.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func (t *TimeoutTransport) RoundTrip(req *http.Request) (*http.Response, error)
8787

8888
select {
8989
case <-timeout:
90+
//nolint:staticcheck
9091
t.Transport.CancelRequest(req)
9192
return nil, errs.ErrHTTPtimeout
9293
case r := <-resp:

0 commit comments

Comments
 (0)