mirror of
https://github.com/Jguer/yay.git
synced 2025-12-27 10:01:53 -05:00
chore(ci): update golangci lint v2.1.5 (#2615)
* chore(ci): update golangci-lint to v2.1.5 in ci.Dockerfile * add golangci * fix lint * fix lint pkg/upgrade * reenable lint
This commit is contained in:
@@ -37,7 +37,7 @@ func (i *InstallInfo) String() string {
|
||||
}
|
||||
|
||||
type (
|
||||
Reason int
|
||||
Reason uint
|
||||
Source int
|
||||
)
|
||||
|
||||
@@ -804,17 +804,17 @@ func makeAURPKGFromSrcinfo(dbExecutor db.Executor, srcInfo *gosrc.Srcinfo) ([]*a
|
||||
Description: getDesc(pkg),
|
||||
URL: pkg.URL,
|
||||
Depends: append(archStringToString(alpmArch, pkg.Depends),
|
||||
archStringToString(alpmArch, srcInfo.Package.Depends)...),
|
||||
MakeDepends: archStringToString(alpmArch, srcInfo.PackageBase.MakeDepends),
|
||||
CheckDepends: archStringToString(alpmArch, srcInfo.PackageBase.CheckDepends),
|
||||
archStringToString(alpmArch, srcInfo.Depends)...),
|
||||
MakeDepends: archStringToString(alpmArch, srcInfo.MakeDepends),
|
||||
CheckDepends: archStringToString(alpmArch, srcInfo.CheckDepends),
|
||||
Conflicts: append(archStringToString(alpmArch, pkg.Conflicts),
|
||||
archStringToString(alpmArch, srcInfo.Package.Conflicts)...),
|
||||
archStringToString(alpmArch, srcInfo.Conflicts)...),
|
||||
Provides: append(archStringToString(alpmArch, pkg.Provides),
|
||||
archStringToString(alpmArch, srcInfo.Package.Provides)...),
|
||||
archStringToString(alpmArch, srcInfo.Provides)...),
|
||||
Replaces: append(archStringToString(alpmArch, pkg.Replaces),
|
||||
archStringToString(alpmArch, srcInfo.Package.Replaces)...),
|
||||
archStringToString(alpmArch, srcInfo.Replaces)...),
|
||||
OptDepends: append(archStringToString(alpmArch, pkg.OptDepends),
|
||||
archStringToString(alpmArch, srcInfo.Package.OptDepends)...),
|
||||
archStringToString(alpmArch, srcInfo.OptDepends)...),
|
||||
Groups: pkg.Groups,
|
||||
License: pkg.License,
|
||||
Keywords: []string{},
|
||||
|
||||
@@ -17,10 +17,10 @@ type IntRange struct {
|
||||
// IntRanges is a slice of IntRange.
|
||||
type IntRanges []IntRange
|
||||
|
||||
func makeIntRange(min, max int) IntRange {
|
||||
func makeIntRange(minVal, maxVal int) IntRange {
|
||||
return IntRange{
|
||||
min,
|
||||
max,
|
||||
min: minVal,
|
||||
max: maxVal,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -64,9 +64,9 @@ func TestParseNumberMenu(t *testing.T) {
|
||||
},
|
||||
mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string](),
|
||||
},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string]("abort", "all", "none"), mapset.NewThreadUnsafeSet[string]()},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string]("a-b"), mapset.NewThreadUnsafeSet[string]("abort", "a-b")},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string]("-9223372036854775809-9223372036854775809"), mapset.NewThreadUnsafeSet[string]()},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet("abort", "all", "none"), mapset.NewThreadUnsafeSet[string]()},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet("a-b"), mapset.NewThreadUnsafeSet("abort", "a-b")},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet("-9223372036854775809-9223372036854775809"), mapset.NewThreadUnsafeSet[string]()},
|
||||
{IntRanges{
|
||||
makeIntRange(1, 1),
|
||||
makeIntRange(2, 2),
|
||||
@@ -86,7 +86,7 @@ func TestParseNumberMenu(t *testing.T) {
|
||||
}, IntRanges{}, mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string]()},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string]()},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string](), mapset.NewThreadUnsafeSet[string]()},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet[string]("a", "b", "c", "d", "e"), mapset.NewThreadUnsafeSet[string]()},
|
||||
{IntRanges{}, IntRanges{}, mapset.NewThreadUnsafeSet("a", "b", "c", "d", "e"), mapset.NewThreadUnsafeSet[string]()},
|
||||
}
|
||||
|
||||
for n, in := range inputs {
|
||||
|
||||
@@ -289,7 +289,7 @@ func matchesSearch(pkg *aur.Pkg, terms []string) bool {
|
||||
desc := strings.ToLower(pkg.Description)
|
||||
targ := strings.ToLower(pkgN)
|
||||
|
||||
if !(strings.Contains(name, targ) || strings.Contains(desc, targ)) {
|
||||
if !strings.Contains(name, targ) && !strings.Contains(desc, targ) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func GetVersionDiff(oldVersion, newVersion string) (left, right string) {
|
||||
}
|
||||
|
||||
for index, char := range oldVersion {
|
||||
charIsSpecial := !(unicode.IsLetter(char) || unicode.IsNumber(char))
|
||||
charIsSpecial := !unicode.IsLetter(char) && !unicode.IsNumber(char)
|
||||
|
||||
if (index >= len(newVersion)) || (char != rune(newVersion[index])) {
|
||||
if charIsSpecial {
|
||||
|
||||
@@ -173,11 +173,12 @@ func (c *CmdBuilder) deElevateCommand(ctx context.Context, cmd *exec.Cmd) *exec.
|
||||
|
||||
if userFound, err := user.Lookup(ogCaller); err == nil {
|
||||
cmd.SysProcAttr = &syscall.SysProcAttr{}
|
||||
uid, _ := strconv.Atoi(userFound.Uid)
|
||||
gid, _ := strconv.Atoi(userFound.Gid)
|
||||
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid), Gid: uint32(gid)}
|
||||
|
||||
return cmd
|
||||
uid64, errUid := strconv.ParseUint(userFound.Uid, 10, 32)
|
||||
gid64, errGid := strconv.ParseUint(userFound.Gid, 10, 32)
|
||||
if errUid == nil && errGid == nil {
|
||||
cmd.SysProcAttr.Credential = &syscall.Credential{Uid: uint32(uid64), Gid: uint32(gid64)}
|
||||
return cmd
|
||||
}
|
||||
}
|
||||
|
||||
cmdArgs := []string{
|
||||
|
||||
@@ -25,7 +25,7 @@ func (o *Option) Add(args ...string) {
|
||||
}
|
||||
|
||||
func (o *Option) First() string {
|
||||
if o.Args == nil || len(o.Args) == 0 {
|
||||
if len(o.Args) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -565,7 +565,6 @@ func (a *Arguments) parseShortOption(arg, param string) (usedNext bool, err erro
|
||||
break
|
||||
} else {
|
||||
err = a.AddArg(char)
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -6,9 +6,10 @@ import (
|
||||
"os/exec"
|
||||
"testing"
|
||||
|
||||
"github.com/Jguer/yay/v12/pkg/settings/exe"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/Jguer/yay/v12/pkg/settings/exe"
|
||||
)
|
||||
|
||||
func TestParsePackageList(t *testing.T) {
|
||||
|
||||
@@ -194,14 +194,15 @@ func (preper *Preparer) PrepareWorkspace(ctx context.Context,
|
||||
|
||||
for _, layer := range targets {
|
||||
for _, info := range layer {
|
||||
if info.Source == dep.AUR {
|
||||
switch info.Source {
|
||||
case dep.AUR:
|
||||
pkgBase := *info.AURBase
|
||||
pkgBuildDir := filepath.Join(preper.cfg.BuildDir, pkgBase)
|
||||
if preper.needToCloneAURBase(info, pkgBuildDir) {
|
||||
aurBasesToClone.Add(pkgBase)
|
||||
}
|
||||
pkgBuildDirsByBase[pkgBase] = pkgBuildDir
|
||||
} else if info.Source == dep.SrcInfo {
|
||||
case dep.SrcInfo:
|
||||
pkgBase := *info.AURBase
|
||||
pkgBuildDirsByBase[pkgBase] = *info.SrcinfoPath
|
||||
}
|
||||
|
||||
@@ -23,12 +23,12 @@ func SplitDBFromName(pkg string) (db, name string) {
|
||||
|
||||
// LessRunes compares two rune values, and returns true if the first argument is lexicographicaly smaller.
|
||||
func LessRunes(iRunes, jRunes []rune) bool {
|
||||
max := len(iRunes)
|
||||
if max > len(jRunes) {
|
||||
max = len(jRunes)
|
||||
maxLen := len(iRunes)
|
||||
if maxLen > len(jRunes) {
|
||||
maxLen = len(jRunes)
|
||||
}
|
||||
|
||||
for idx := 0; idx < max; idx++ {
|
||||
for idx := 0; idx < maxLen; idx++ {
|
||||
ir := iRunes[idx]
|
||||
jr := jRunes[idx]
|
||||
|
||||
|
||||
@@ -201,7 +201,8 @@ func (u *UpgradeService) graphToUpSlice(graph *topo.Graph[string, *dep.InstallIn
|
||||
extra = fmt.Sprintf(" (%s of %s)", dep.ReasonNames[info.Reason], strings.Join(reducedParents, ", "))
|
||||
}
|
||||
|
||||
if info.Source == dep.AUR {
|
||||
switch info.Source {
|
||||
case dep.AUR:
|
||||
aurRepo := "aur"
|
||||
if info.Devel {
|
||||
aurRepo = "devel"
|
||||
@@ -215,7 +216,7 @@ func (u *UpgradeService) graphToUpSlice(graph *topo.Graph[string, *dep.InstallIn
|
||||
Reason: alpmReason,
|
||||
Extra: extra,
|
||||
})
|
||||
} else if info.Source == dep.Sync {
|
||||
case dep.Sync:
|
||||
repoUp.Up = append(repoUp.Up, Upgrade{
|
||||
Name: name,
|
||||
RemoteVersion: info.Version,
|
||||
|
||||
@@ -38,9 +38,10 @@ func (u UpSlice) Less(i, j int) bool {
|
||||
}
|
||||
|
||||
for _, db := range u.Repos {
|
||||
if db == u.Up[i].Repository {
|
||||
switch db {
|
||||
case u.Up[i].Repository:
|
||||
return true
|
||||
} else if db == u.Up[j].Repository {
|
||||
case u.Up[j].Repository:
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -52,9 +53,7 @@ func (u UpSlice) Less(i, j int) bool {
|
||||
}
|
||||
|
||||
// calculateFormatting calculates formatting parameters for printing upgrades
|
||||
func calculateFormatting(upgrades []Upgrade) (int, int, int) {
|
||||
longestName, longestVersion := 0, 0
|
||||
|
||||
func calculateFormatting(upgrades []Upgrade) (longestName, longestVersion, longestNumber int) {
|
||||
for i := range upgrades {
|
||||
upgrade := &upgrades[i]
|
||||
packNameLen := len(StylizedNameWithRepository(upgrade))
|
||||
@@ -65,9 +64,9 @@ func calculateFormatting(upgrades []Upgrade) (int, int, int) {
|
||||
}
|
||||
|
||||
lenUp := len(upgrades)
|
||||
longestNumber := len(fmt.Sprintf("%v", lenUp))
|
||||
longestNumber = len(fmt.Sprintf("%v", lenUp))
|
||||
|
||||
return longestName, longestVersion, longestNumber
|
||||
return
|
||||
}
|
||||
|
||||
// Print prints the details of the packages to upgrade.
|
||||
|
||||
Reference in New Issue
Block a user