Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
go-version-file: go.mod
check-latest: true

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

Expand Down
36 changes: 18 additions & 18 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
version: "2"
run:
timeout: 10m

# Run linters over integration tests
build-tags:
- integration

linters:
disable-all: true # Disable defaults, then enable the ones we want
default: none
enable:
- errcheck
- gosimple
- gosec
- govet
- ineffassign
- staticcheck
# - structcheck https://github.com/golangci/golangci-lint/issues/2649
- typecheck
- unused
# - bodyclose Disabled so concurrent GETs can happen
- stylecheck
- gosec
settings:
staticcheck:
checks:
- -SA1019
- all
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
formatters:
enable:
- gofmt
- goimports
- gci

linters-settings:
staticcheck:
checks:
- all
- "-SA1019" # Disable "rand.Seed has been deprecated"
2 changes: 1 addition & 1 deletion cmd/cryptography/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func GenerateChecksum(sourcePack, destinationDir, hashFunction string) error {
}
base = filepath.Clean(destinationDir) + string(filepath.Separator) + strings.TrimSuffix(string(filepath.Base(sourcePack)), ".pack")
}
checksumFilename := base + "." + strings.Replace(hashFunction, "-", "", -1) + ".checksum"
checksumFilename := base + "." + strings.ReplaceAll(hashFunction, "-", "") + ".checksum"
if utils.FileExists(checksumFilename) {
log.Errorf("\"%s\" already exists, choose a diferent path", checksumFilename)
return errs.ErrPathAlreadyExists
Expand Down
4 changes: 2 additions & 2 deletions cmd/installer/pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -453,11 +453,11 @@ func (p *PackType) uninstall(installation *PacksInstallationType) error {
func (p *PackType) readEula() ([]byte, error) {
log.Debug("Reading EULA")

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

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

reader, _ := file.Open()
Expand Down
9 changes: 5 additions & 4 deletions cmd/installer/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -915,12 +915,12 @@ func findInstalledPacks(addLocalPacks, removeDuplicates bool) ([]installedPack,
return nil, err
}
for _, match := range matches {
pdscPath := strings.Replace(match, Installation.PackRoot, "", -1)
pdscPath := strings.ReplaceAll(match, Installation.PackRoot, "")
packName, _ := filepath.Split(pdscPath)
packName = strings.Replace(packName, "/", " ", -1)
packName = strings.Replace(packName, "\\", " ", -1)
packName = strings.ReplaceAll(packName, "/", " ")
packName = strings.ReplaceAll(packName, "\\", " ")
packName = strings.Trim(packName, " ")
packName = strings.Replace(packName, " ", ".", -1)
packName = strings.ReplaceAll(packName, " ", ".")

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

Expand Down Expand Up @@ -978,6 +978,7 @@ func findInstalledPacks(addLocalPacks, removeDuplicates bool) ([]installedPack,
noDupInstalledPacks = append(noDupInstalledPacks, installedPacks[0])
for i, installedPack := range installedPacks {
if i > 0 {
//nolint:staticcheck // intentional logic for clarity
if !(installedPacks[last].Vendor == installedPack.Vendor && installedPacks[last].Name == installedPack.Name) {
noDupInstalledPacks = append(noDupInstalledPacks, installedPack)
last = i
Expand Down
16 changes: 8 additions & 8 deletions cmd/installer/root_pack_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func ExampleListInstalledPacks_list() {
_ = installer.ReadIndexFiles()
defer removePackRoot(localTestingDir)

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

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

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

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

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

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

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

pdscFilePath := strings.Replace(publicLocalPack123, ".1.2.3.pack", ".pdsc", -1)
pdscFilePath := strings.ReplaceAll(publicLocalPack123, ".1.2.3.pack", ".pdsc")
_ = utils.CopyFile(pdscFilePath, filepath.Join(installer.Installation.WebDir, "TheVendor.PublicLocalPack.pdsc"))
_ = installer.Installation.PublicIndexXML.AddPdsc(xml.PdscTag{
Vendor: "TheVendor",
Expand Down
6 changes: 3 additions & 3 deletions cmd/installer/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ func TestUpdatePublicIndex(t *testing.T) {
assert.Nil(err)
indexServer := NewServer()
// The psd URL needs to be updated as it's not known beforehand
updatedIndex := []byte(strings.Replace(string(indexContent), "https://127.0.0.1", indexServer.URL(), -1))
updatedIndex := []byte(strings.ReplaceAll(string(indexContent), "https://127.0.0.1", indexServer.URL()))
indexServer.AddRoute(installer.PublicIndex, updatedIndex)
indexPath := indexServer.URL() + installer.PublicIndex

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

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

Expand Down
2 changes: 1 addition & 1 deletion cmd/ui/eula.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func NewLicenseWindow(licenseTitle, licenseContents, promptText string) *License
}
v.Wrap = true
v.Title = licenseTitle
fmt.Fprint(v, strings.Replace(licenseContents, "\r", "", -1))
fmt.Fprint(v, strings.ReplaceAll(licenseContents, "\r", ""))
}

// Prompt window dimensions
Expand Down
1 change: 1 addition & 0 deletions cmd/utils/packs.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ func ExtractPackInfo(packPath string) (PackInfo, error) {
// location can be either a URL or a path to the local
// file system. If it's the latter, make sure to fill in
// in case the file is coming from the current directory
//nolint:staticcheck // intentional logic for clarity
if !(strings.HasPrefix(location, "http://") || strings.HasPrefix(location, "https://") || strings.HasPrefix(location, "file://")) {
if !filepath.IsAbs(location) {
if len(filepath.VolumeName(location)) == 0 && len(location) > 0 && (location[0] == '/' || location[0] == '\\') {
Expand Down
1 change: 1 addition & 0 deletions cmd/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func (t *TimeoutTransport) RoundTrip(req *http.Request) (*http.Response, error)

select {
case <-timeout:
//nolint:staticcheck
t.Transport.CancelRequest(req)
return nil, errs.ErrHTTPtimeout
case r := <-resp:
Expand Down
Loading