Browse Source

chore(yay): fix small linting issues (#1885)

* replace context.TODO() in tests context.Background()

* remove mock TODOs

* prettier

* apply missing linting
Jo 2 years ago
parent
commit
b8debd1ae7

+ 9 - 6
.golangci.yml

@@ -25,10 +25,10 @@ linters-settings:
       - condition
       - return
     ignored-numbers:
-      - '0'
-      - '1'
-      - '2'
-      - '3'
+      - "0"
+      - "1"
+      - "2"
+      - "3"
     ignored-functions:
       - strings.SplitN
   govet:
@@ -51,6 +51,7 @@ linters:
     - depguard
     - dogsled
     - dupl
+    - errorlint
     - errcheck
     - exportloopref
     # - funlen # TOFIX
@@ -80,11 +81,12 @@ linters:
     - whitespace
 
 run:
-  go: '1.18'
+  go: "1.18"
+  timeout: "10m"
 
 issues:
   exclude-rules:
-    - path: _test\.go
+    - path: (.+)_test.go
       linters:
         - lll
         - revive
@@ -96,6 +98,7 @@ issues:
         - dupl
         - gocritic
         - gochecknoinits
+        - errorlint
 
   exclude:
     - G204

+ 50 - 51
README.md

@@ -49,7 +49,6 @@ If you want to do all of this at once, we can chain the commands like so:
 pacman -S --needed git base-devel && git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si
 ```
 
-
 ### Binary
 
 If you do not want to compile yay yourself you can use the builds generated by
@@ -88,90 +87,90 @@ pacman -S --needed git base-devel yay
 
 ## Examples of Custom Operations
 
-| Command                           | Description                                                                                         |
-| --------------------------------- | --------------------------------------------------------------------------------------------------- |
-| `yay`                             | Alias to `yay -Syu`.                                                                                |
-| `yay <Search Term>`               | Present package-installation selection menu.                                                        |
-| `yay -Y --combinedupgrade --save` | Make combined upgrade the default mode.                                                             |
-| `yay -Ps`                         | Print system statistics.                                                                            |
-| `yay -Yc`                         | Clean unneeded dependencies.                                                                        |
-| `yay -G <AUR Package>`            | Download PKGBUILD from ABS or AUR.                                                                  |
-| `yay -Gp <AUR Package>`           | Print to stdout PKGBUILD from ABS or AUR.                                                           |
-| `yay -Y --gendb`                  | Generate development package database used for devel update.                                        |
-| `yay -Syu --devel`                | Perform system upgrade, but also check for development package updates.                             |
-| `yay -Syu --timeupdate`           | Perform system upgrade and use PKGBUILD modification time (not version number) to determine update. |
-| `yay -Wv <AUR Package>`           | Vote for package (Requires setting `AUR_USERNAME` and `AUR_PASSWORD` environment variables). (yay v11.3+) |
-| `yay -Wu <AUR Package>`           | Unvote for package (Requires setting `AUR_USERNAME` and `AUR_PASSWORD` environment variables) (yay v11.3+)|
+| Command                           | Description                                                                                                |
+| --------------------------------- | ---------------------------------------------------------------------------------------------------------- |
+| `yay`                             | Alias to `yay -Syu`.                                                                                       |
+| `yay <Search Term>`               | Present package-installation selection menu.                                                               |
+| `yay -Y --combinedupgrade --save` | Make combined upgrade the default mode.                                                                    |
+| `yay -Ps`                         | Print system statistics.                                                                                   |
+| `yay -Yc`                         | Clean unneeded dependencies.                                                                               |
+| `yay -G <AUR Package>`            | Download PKGBUILD from ABS or AUR.                                                                         |
+| `yay -Gp <AUR Package>`           | Print to stdout PKGBUILD from ABS or AUR.                                                                  |
+| `yay -Y --gendb`                  | Generate development package database used for devel update.                                               |
+| `yay -Syu --devel`                | Perform system upgrade, but also check for development package updates.                                    |
+| `yay -Syu --timeupdate`           | Perform system upgrade and use PKGBUILD modification time (not version number) to determine update.        |
+| `yay -Wv <AUR Package>`           | Vote for package (Requires setting `AUR_USERNAME` and `AUR_PASSWORD` environment variables). (yay v11.3+)  |
+| `yay -Wu <AUR Package>`           | Unvote for package (Requires setting `AUR_USERNAME` and `AUR_PASSWORD` environment variables) (yay v11.3+) |
 
 ## Frequently Asked Questions
 
 - **Yay does not display colored output. How do I fix it?**
 
-    Make sure you have the `Color` option in your `/etc/pacman.conf`
-    (see issue [#123](https://github.com/Jguer/yay/issues/123)).
+  Make sure you have the `Color` option in your `/etc/pacman.conf`
+  (see issue [#123](https://github.com/Jguer/yay/issues/123)).
 
 - **Yay is not prompting to skip packages during system upgrade.**
 
-    The default behavior was changed after
-    [v8.918](https://github.com/Jguer/yay/releases/tag/v8.918)
-    (see [3bdb534](https://github.com/Jguer/yay/commit/3bdb5343218d99d40f8a449b887348611f6bdbfc)
-    and issue [#554](https://github.com/Jguer/yay/issues/554)).
-    To restore the package-skip behavior use `--combinedupgrade` (make
-    it permanent by appending `--save`). Note: skipping packages will leave your
-    system in a
-    [partially-upgraded state](https://wiki.archlinux.org/index.php/System_maintenance#Partial_upgrades_are_unsupported).
+  The default behavior was changed after
+  [v8.918](https://github.com/Jguer/yay/releases/tag/v8.918)
+  (see [3bdb534](https://github.com/Jguer/yay/commit/3bdb5343218d99d40f8a449b887348611f6bdbfc)
+  and issue [#554](https://github.com/Jguer/yay/issues/554)).
+  To restore the package-skip behavior use `--combinedupgrade` (make
+  it permanent by appending `--save`). Note: skipping packages will leave your
+  system in a
+  [partially-upgraded state](https://wiki.archlinux.org/index.php/System_maintenance#Partial_upgrades_are_unsupported).
 
 - **Sometimes diffs are printed to the terminal, and other times they are paged via less. How do I fix this?**
 
-    Yay uses `git diff` to display diffs, which by default tells less not to
-    page if the output can fit into one terminal length. This behavior can be
-    overridden by exporting your own flags (`export LESS=SRX`).
+  Yay uses `git diff` to display diffs, which by default tells less not to
+  page if the output can fit into one terminal length. This behavior can be
+  overridden by exporting your own flags (`export LESS=SRX`).
 
 - **Yay is not asking me to edit PKGBUILDS, and I don't like the diff menu! What can I do?**
 
-    `yay --editmenu --nodiffmenu --save`
+  `yay --editmenu --nodiffmenu --save`
 
 - **How can I tell Yay to act only on AUR packages, or only on repo packages?**
 
-    `yay -{OPERATION} --aur`
-    `yay -{OPERATION} --repo`
+  `yay -{OPERATION} --aur`
+  `yay -{OPERATION} --repo`
 
 - **An `Out Of Date AUR Packages` message is displayed. Why doesn't Yay update them?**
 
-    This message does not mean that updated AUR packages are available. It means
-    the packages have been flagged out of date on the AUR, but
-    their maintainers have not yet updated the `PKGBUILD`s
-    (see [outdated AUR packages](https://wiki.archlinux.org/index.php/Arch_User_Repository#Foo_in_the_AUR_is_outdated.3B_what_should_I_do.3F)).
+  This message does not mean that updated AUR packages are available. It means
+  the packages have been flagged out of date on the AUR, but
+  their maintainers have not yet updated the `PKGBUILD`s
+  (see [outdated AUR packages](https://wiki.archlinux.org/index.php/Arch_User_Repository#Foo_in_the_AUR_is_outdated.3B_what_should_I_do.3F)).
 
 - **Yay doesn't install dependencies added to a PKGBUILD during installation.**
 
-    Yay resolves all dependencies ahead of time. You are free to edit the
-    PKGBUILD in any way, but any problems you cause are your own and should not be
-    reported unless they can be reproduced with the original PKGBUILD.
+  Yay resolves all dependencies ahead of time. You are free to edit the
+  PKGBUILD in any way, but any problems you cause are your own and should not be
+  reported unless they can be reproduced with the original PKGBUILD.
 
 - **I know my `-git` package has updates but yay doesn't offer to update it**
 
-    Yay uses an hash cache for development packages. Normally it is updated at the end of the package install with the message `Found git repo`.
-    If you transition between aur helpers and did not install the devel package using yay at some point, it is possible it never got added to the cache. `yay -Y --gendb` will fix the current version of every devel package and start checking from there.
+  Yay uses an hash cache for development packages. Normally it is updated at the end of the package install with the message `Found git repo`.
+  If you transition between aur helpers and did not install the devel package using yay at some point, it is possible it never got added to the cache. `yay -Y --gendb` will fix the current version of every devel package and start checking from there.
 
 - **I want to help out!**
 
-    Check [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
+  Check [CONTRIBUTING.md](./CONTRIBUTING.md) for more information.
 
 - **What settings do you use?**
 
-    ```sh
-    yay -Y --devel --combinedupgrade --batchinstall --save
-    ```
+  ```sh
+  yay -Y --devel --combinedupgrade --batchinstall --save
+  ```
 
-    Pacman conf options:
+  Pacman conf options:
 
-    ```conf
-    UseSyslog
-    Color
-    CheckSpace
-    VerbosePkgLists
-    ```
+  ```conf
+  UseSyslog
+  Color
+  CheckSpace
+  VerbosePkgLists
+  ```
 
 ## Support
 

+ 5 - 5
aur_source_test.go

@@ -54,7 +54,7 @@ func Test_downloadPKGBUILDSource(t *testing.T) {
 		want:          "makepkg --nocheck --config /etc/not.conf --verifysource -Ccf",
 		wantDir:       "/tmp/yay-bin",
 	}
-	err := downloadPKGBUILDSource(context.TODO(), cmdBuilder, filepath.Join("/tmp", "yay-bin"), false)
+	err := downloadPKGBUILDSource(context.Background(), cmdBuilder, filepath.Join("/tmp", "yay-bin"), false)
 	assert.NoError(t, err)
 	assert.Equal(t, 1, int(cmdBuilder.passes))
 }
@@ -71,7 +71,7 @@ func Test_downloadPKGBUILDSourceError(t *testing.T) {
 		wantDir:       "/tmp/yay-bin",
 		showError:     &exec.ExitError{},
 	}
-	err := downloadPKGBUILDSource(context.TODO(), cmdBuilder, filepath.Join("/tmp", "yay-bin"), false)
+	err := downloadPKGBUILDSource(context.Background(), cmdBuilder, filepath.Join("/tmp", "yay-bin"), false)
 	assert.Error(t, err)
 	assert.EqualError(t, err, "error downloading sources: \x1b[36m/tmp/yay-bin\x1b[0m \n\t context: <nil> \n\t \n")
 }
@@ -99,7 +99,7 @@ func Test_downloadPKGBUILDSourceFanout(t *testing.T) {
 				test: t,
 			}
 
-			err := downloadPKGBUILDSourceFanout(context.TODO(), cmdBuilder, pkgBuildDirs, false, maxConcurrentDownloads)
+			err := downloadPKGBUILDSourceFanout(context.Background(), cmdBuilder, pkgBuildDirs, false, maxConcurrentDownloads)
 			assert.NoError(t, err)
 			assert.Equal(t, 5, int(cmdBuilder.passes))
 		})
@@ -121,7 +121,7 @@ func Test_downloadPKGBUILDSourceFanoutNoCC(t *testing.T) {
 
 	pkgBuildDirs := map[string]string{"yay": "/tmp/yay"}
 
-	err := downloadPKGBUILDSourceFanout(context.TODO(), cmdBuilder, pkgBuildDirs, false, 0)
+	err := downloadPKGBUILDSourceFanout(context.Background(), cmdBuilder, pkgBuildDirs, false, 0)
 	assert.NoError(t, err)
 	assert.Equal(t, 1, int(cmdBuilder.passes))
 }
@@ -148,7 +148,7 @@ func Test_downloadPKGBUILDSourceFanoutError(t *testing.T) {
 		"yay-v12": "/tmp/yay-v12",
 	}
 
-	err := downloadPKGBUILDSourceFanout(context.TODO(), cmdBuilder, pkgBuildDirs, false, 0)
+	err := downloadPKGBUILDSourceFanout(context.Background(), cmdBuilder, pkgBuildDirs, false, 0)
 	assert.Error(t, err)
 	assert.Equal(t, 5, int(cmdBuilder.passes))
 	assert.Len(t, err.(*multierror.MultiError).Errors, 5)

+ 4 - 2
get.go

@@ -17,7 +17,8 @@ import (
 
 // yay -Gp.
 func printPkgbuilds(dbExecutor download.DBSearcher, httpClient *http.Client, targets []string,
-	mode parser.TargetMode, aurURL string) error {
+	mode parser.TargetMode, aurURL string,
+) error {
 	pkgbuilds, err := download.PKGBUILDs(dbExecutor, httpClient, targets, aurURL, mode)
 	if err != nil {
 		text.Errorln(err)
@@ -49,7 +50,8 @@ func printPkgbuilds(dbExecutor download.DBSearcher, httpClient *http.Client, tar
 
 // yay -G.
 func getPkgbuilds(ctx context.Context, dbExecutor download.DBSearcher,
-	config *settings.Configuration, targets []string, force bool) error {
+	config *settings.Configuration, targets []string, force bool,
+) error {
 	wd, err := os.Getwd()
 	if err != nil {
 		return err

+ 1 - 1
install.go

@@ -504,7 +504,7 @@ func parsePackageList(ctx context.Context, cmdBuilder exe.ICmdBuilder,
 	stdout, stderr, err := cmdBuilder.Capture(
 		cmdBuilder.BuildMakepkgCmd(ctx, dir, "--packagelist"))
 	if err != nil {
-		return nil, "", fmt.Errorf("%s %s", stderr, err)
+		return nil, "", fmt.Errorf("%s %w", stderr, err)
 	}
 
 	lines := strings.Split(stdout, "\n")

+ 3 - 1
main.go

@@ -2,6 +2,7 @@ package main // import "github.com/Jguer/yay"
 
 import (
 	"context"
+	"errors"
 	"os"
 	"os/exec"
 	"runtime/debug"
@@ -146,7 +147,8 @@ func main() {
 			text.Errorln(str)
 		}
 
-		if exitError, ok := err.(*exec.ExitError); ok {
+		exitError := &exec.ExitError{}
+		if errors.As(err, &exitError) {
 			// mirror pacman exit code when applicable
 			ret = exitError.ExitCode()
 			return

+ 3 - 3
pkg/completion/completion_test.go

@@ -59,7 +59,7 @@ func Test_createAURList(t *testing.T) {
 		returnErr:        nil,
 	}
 	out := &bytes.Buffer{}
-	err := createAURList(context.TODO(), doer, "https://aur.archlinux.org", out)
+	err := createAURList(context.Background(), doer, "https://aur.archlinux.org", out)
 	assert.NoError(t, err)
 	gotOut := out.String()
 	assert.Equal(t, expectPackageCompletion, gotOut)
@@ -76,7 +76,7 @@ func Test_createAURListHTTPError(t *testing.T) {
 	}
 
 	out := &bytes.Buffer{}
-	err := createAURList(context.TODO(), doer, "https://aur.archlinux.org", out)
+	err := createAURList(context.Background(), doer, "https://aur.archlinux.org", out)
 	assert.EqualError(t, err, "Not available")
 }
 
@@ -91,6 +91,6 @@ func Test_createAURListStatusError(t *testing.T) {
 	}
 
 	out := &bytes.Buffer{}
-	err := createAURList(context.TODO(), doer, "https://aur.archlinux.org", out)
+	err := createAURList(context.Background(), doer, "https://aur.archlinux.org", out)
 	assert.EqualError(t, err, "invalid status code: 503")
 }

+ 24 - 24
pkg/db/mock/repo.go

@@ -60,30 +60,30 @@ func (p *Package) Reason() alpm.PkgReason {
 }
 
 func (p *Package) FileName() string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 func (p *Package) Base64Signature() string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 func (p *Package) Validation() alpm.Validation {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Architecture returns the package target Architecture.
 func (p *Package) Architecture() string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Backup returns a list of package backups.
 func (p *Package) Backup() alpm.BackupList {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Conflicts returns the conflicts of the package as a DependList.
 func (p *Package) Conflicts() alpm.DependList {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Depends returns the package's dependency list.
@@ -93,57 +93,57 @@ func (p *Package) Depends() alpm.DependList {
 
 // Depends returns the package's optional dependency list.
 func (p *Package) OptionalDepends() alpm.DependList {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Depends returns the package's check dependency list.
 func (p *Package) CheckDepends() alpm.DependList {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Depends returns the package's make dependency list.
 func (p *Package) MakeDepends() alpm.DependList {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Files returns the file list of the package.
 func (p *Package) Files() []alpm.File {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // ContainsFile checks if the path is in the package filelist.
 func (p *Package) ContainsFile(path string) (alpm.File, error) {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Groups returns the groups the package belongs to.
 func (p *Package) Groups() alpm.StringList {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // InstallDate returns the package install date.
 func (p *Package) InstallDate() time.Time {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Licenses returns the package license list.
 func (p *Package) Licenses() alpm.StringList {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // SHA256Sum returns package SHA256Sum.
 func (p *Package) SHA256Sum() string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // MD5Sum returns package MD5Sum.
 func (p *Package) MD5Sum() string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Packager returns package packager name.
 func (p *Package) Packager() string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Provides returns DependList of packages provides by package.
@@ -153,38 +153,38 @@ func (p *Package) Provides() alpm.DependList {
 
 // Origin returns package origin.
 func (p *Package) Origin() alpm.PkgFrom {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // Replaces returns a DependList with the packages this package replaces.
 func (p *Package) Replaces() alpm.DependList {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // URL returns the upstream URL of the package.
 func (p *Package) URL() string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // ComputeRequiredBy returns the names of reverse dependencies of a package.
 func (p *Package) ComputeRequiredBy() []string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // ComputeOptionalFor returns the names of packages that optionally
 // require the given package.
 func (p *Package) ComputeOptionalFor() []string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 // SyncNewVersion checks if there is a new version of the
 // package in a given DBlist.
 func (p *Package) SyncNewVersion(l alpm.IDBList) alpm.IPackage {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 func (p *Package) Type() string {
-	panic("not implemented") // TODO: Implement
+	panic("not implemented")
 }
 
 type DB struct {

+ 2 - 1
pkg/download/abs.go

@@ -85,7 +85,8 @@ func ABSPKGBUILD(httpClient httpRequestDoer, dbName, pkgName string) ([]byte, er
 
 // ABSPKGBUILDRepo retrieves the PKGBUILD repository to a dest directory.
 func ABSPKGBUILDRepo(ctx context.Context, cmdBuilder exe.GitCmdBuilder,
-	dbName, pkgName, dest string, force bool) (bool, error) {
+	dbName, pkgName, dest string, force bool,
+) (bool, error) {
 	pkgURL, err := getPackageRepoURL(dbName)
 	if err != nil {
 		return false, err

+ 2 - 2
pkg/download/abs_test.go

@@ -219,7 +219,7 @@ func TestABSPKGBUILDRepo(t *testing.T) {
 			GitFlags: []string{"--no-replace-objects"},
 		},
 	}
-	newClone, err := ABSPKGBUILDRepo(context.TODO(), cmdBuilder, "core", "linux", "/tmp/doesnt-exist", false)
+	newClone, err := ABSPKGBUILDRepo(context.Background(), cmdBuilder, "core", "linux", "/tmp/doesnt-exist", false)
 	assert.NoError(t, err)
 	assert.Equal(t, true, newClone)
 }
@@ -253,7 +253,7 @@ func TestABSPKGBUILDRepoExistsPerms(t *testing.T) {
 			GitFlags: []string{"--no-replace-objects"},
 		},
 	}
-	newClone, err := ABSPKGBUILDRepo(context.TODO(), cmdBuilder, "core", "linux", dir, false)
+	newClone, err := ABSPKGBUILDRepo(context.Background(), cmdBuilder, "core", "linux", dir, false)
 	assert.NoError(t, err)
 	assert.Equal(t, false, newClone)
 }

+ 2 - 1
pkg/download/aur.go

@@ -49,7 +49,8 @@ func AURPKGBUILDRepo(ctx context.Context, cmdBuilder exe.GitCmdBuilder, aurURL,
 func AURPKGBUILDRepos(
 	ctx context.Context,
 	cmdBuilder exe.GitCmdBuilder,
-	targets []string, aurURL, dest string, force bool) (map[string]bool, error) {
+	targets []string, aurURL, dest string, force bool,
+) (map[string]bool, error) {
 	cloned := make(map[string]bool, len(targets))
 
 	var (

+ 3 - 3
pkg/download/aur_test.go

@@ -98,7 +98,7 @@ func TestAURPKGBUILDRepo(t *testing.T) {
 			GitFlags: []string{"--no-replace-objects"},
 		},
 	}
-	newCloned, err := AURPKGBUILDRepo(context.TODO(), cmdBuilder, "https://aur.archlinux.org", "yay-bin", "/tmp/doesnt-exist", false)
+	newCloned, err := AURPKGBUILDRepo(context.Background(), cmdBuilder, "https://aur.archlinux.org", "yay-bin", "/tmp/doesnt-exist", false)
 	assert.NoError(t, err)
 	assert.Equal(t, true, newCloned)
 }
@@ -132,7 +132,7 @@ func TestAURPKGBUILDRepoExistsPerms(t *testing.T) {
 			GitFlags: []string{"--no-replace-objects"},
 		},
 	}
-	cloned, err := AURPKGBUILDRepo(context.TODO(), cmdBuilder, "https://aur.archlinux.org", "yay-bin", dir, false)
+	cloned, err := AURPKGBUILDRepo(context.Background(), cmdBuilder, "https://aur.archlinux.org", "yay-bin", dir, false)
 	assert.NoError(t, err)
 	assert.Equal(t, false, cloned)
 }
@@ -155,7 +155,7 @@ func TestAURPKGBUILDRepos(t *testing.T) {
 			GitFlags: []string{},
 		},
 	}
-	cloned, err := AURPKGBUILDRepos(context.TODO(), cmdBuilder, targets, "https://aur.archlinux.org", dir, false)
+	cloned, err := AURPKGBUILDRepos(context.Background(), cmdBuilder, targets, "https://aur.archlinux.org", dir, false)
 
 	assert.NoError(t, err)
 	assert.EqualValues(t, map[string]bool{"yay": true, "yay-bin": false, "yay-git": true}, cloned)

+ 6 - 3
pkg/download/unified.go

@@ -26,7 +26,8 @@ type DBSearcher interface {
 }
 
 func downloadGitRepo(ctx context.Context, cmdBuilder exe.GitCmdBuilder,
-	pkgURL, pkgName, dest string, force bool, gitArgs ...string) (bool, error) {
+	pkgURL, pkgName, dest string, force bool, gitArgs ...string,
+) (bool, error) {
 	finalDir := filepath.Join(dest, pkgName)
 	newClone := true
 
@@ -79,7 +80,8 @@ func getURLName(pkg db.IPackage) string {
 }
 
 func PKGBUILDs(dbExecutor DBSearcher, httpClient *http.Client, targets []string,
-	aurURL string, mode parser.TargetMode) (map[string][]byte, error) {
+	aurURL string, mode parser.TargetMode,
+) (map[string][]byte, error) {
 	pkgbuilds := make(map[string][]byte, len(targets))
 
 	var (
@@ -133,7 +135,8 @@ func PKGBUILDs(dbExecutor DBSearcher, httpClient *http.Client, targets []string,
 
 func PKGBUILDRepos(ctx context.Context, dbExecutor DBSearcher,
 	cmdBuilder exe.GitCmdBuilder,
-	targets []string, mode parser.TargetMode, aurURL, dest string, force bool) (map[string]bool, error) {
+	targets []string, mode parser.TargetMode, aurURL, dest string, force bool,
+) (map[string]bool, error) {
 	cloned := make(map[string]bool, len(targets))
 
 	var (

+ 5 - 5
pkg/download/unified_test.go

@@ -38,7 +38,7 @@ func TestPKGBUILDReposDefinedDBPull(t *testing.T) {
 	searcher := &testDBSearcher{
 		absPackagesDB: map[string]string{"yay": "core"},
 	}
-	cloned, err := PKGBUILDRepos(context.TODO(), searcher,
+	cloned, err := PKGBUILDRepos(context.Background(), searcher,
 		cmdBuilder,
 		targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
 
@@ -67,7 +67,7 @@ func TestPKGBUILDReposDefinedDBClone(t *testing.T) {
 	searcher := &testDBSearcher{
 		absPackagesDB: map[string]string{"yay": "core"},
 	}
-	cloned, err := PKGBUILDRepos(context.TODO(), searcher,
+	cloned, err := PKGBUILDRepos(context.Background(), searcher,
 		cmdBuilder,
 		targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
 
@@ -96,7 +96,7 @@ func TestPKGBUILDReposClone(t *testing.T) {
 	searcher := &testDBSearcher{
 		absPackagesDB: map[string]string{"yay": "core"},
 	}
-	cloned, err := PKGBUILDRepos(context.TODO(), searcher,
+	cloned, err := PKGBUILDRepos(context.Background(), searcher,
 		cmdBuilder,
 		targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
 
@@ -125,7 +125,7 @@ func TestPKGBUILDReposNotFound(t *testing.T) {
 	searcher := &testDBSearcher{
 		absPackagesDB: map[string]string{"yay": "core"},
 	}
-	cloned, err := PKGBUILDRepos(context.TODO(), searcher,
+	cloned, err := PKGBUILDRepos(context.Background(), searcher,
 		cmdBuilder,
 		targets, parser.ModeAny, "https://aur.archlinux.org", dir, false)
 
@@ -154,7 +154,7 @@ func TestPKGBUILDReposRepoMode(t *testing.T) {
 	searcher := &testDBSearcher{
 		absPackagesDB: map[string]string{"yay": "core"},
 	}
-	cloned, err := PKGBUILDRepos(context.TODO(), searcher,
+	cloned, err := PKGBUILDRepos(context.Background(), searcher,
 		cmdBuilder,
 		targets, parser.ModeRepo, "https://aur.archlinux.org", dir, false)
 

+ 2 - 1
pkg/intrange/intrange.go

@@ -71,7 +71,8 @@ func Max(a, b int) int {
 // of course the implementation is up to the caller, this function mearley parses
 // the input and organizes it.
 func ParseNumberMenu(input string) (include, exclude IntRanges,
-	otherInclude, otherExclude stringset.StringSet) {
+	otherInclude, otherExclude stringset.StringSet,
+) {
 	include = make(IntRanges, 0)
 	exclude = make(IntRanges, 0)
 	otherInclude = make(stringset.StringSet)

+ 3 - 3
pkg/menus/diff_menu.go

@@ -76,7 +76,7 @@ func gitHasDiff(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string) (bo
 		stdout, stderr, err := cmdBuilder.Capture(
 			cmdBuilder.BuildGitCmd(ctx, dir, "rev-parse", gitDiffRefName, "HEAD@{upstream}"))
 		if err != nil {
-			return false, fmt.Errorf("%s%s", stderr, err)
+			return false, fmt.Errorf("%s%w", stderr, err)
 		}
 
 		lines := strings.Split(stdout, "\n")
@@ -108,7 +108,7 @@ func getLastSeenHash(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir string
 			cmdBuilder.BuildGitCmd(ctx,
 				dir, "rev-parse", gitDiffRefName))
 		if err != nil {
-			return "", fmt.Errorf("%s %s", stderr, err)
+			return "", fmt.Errorf("%s %w", stderr, err)
 		}
 
 		lines := strings.Split(stdout, "\n")
@@ -126,7 +126,7 @@ func gitUpdateSeenRef(ctx context.Context, cmdBuilder exe.ICmdBuilder, dir strin
 		cmdBuilder.BuildGitCmd(ctx,
 			dir, "update-ref", gitDiffRefName, "HEAD"))
 	if err != nil {
-		return fmt.Errorf("%s %s", stderr, err)
+		return fmt.Errorf("%s %w", stderr, err)
 	}
 
 	return nil

+ 2 - 2
pkg/news/news_test.go

@@ -135,7 +135,7 @@ func TestPrintNewsFeed(t *testing.T) {
 			r, w, _ := os.Pipe()
 			os.Stdout = w
 
-			err := PrintNewsFeed(context.TODO(), &http.Client{}, tt.args.cutOffDate, tt.args.bottomUp, tt.args.all, tt.args.quiet)
+			err := PrintNewsFeed(context.Background(), &http.Client{}, tt.args.cutOffDate, tt.args.bottomUp, tt.args.all, tt.args.quiet)
 			assert.NoError(t, err)
 
 			w.Close()
@@ -164,7 +164,7 @@ func TestPrintNewsFeedSameDay(t *testing.T) {
 	r, w, _ := os.Pipe()
 	os.Stdout = w
 
-	err := PrintNewsFeed(context.TODO(), &http.Client{}, lastNewsTime, true, false, false)
+	err := PrintNewsFeed(context.Background(), &http.Client{}, lastNewsTime, true, false, false)
 	assert.NoError(t, err)
 
 	w.Close()

+ 3 - 1
pkg/settings/exe/exec.go

@@ -1,6 +1,7 @@
 package exe
 
 import (
+	"errors"
 	"os"
 	"os/exec"
 	"strings"
@@ -27,7 +28,8 @@ func (r *OSRunner) Capture(cmd *exec.Cmd) (stdout, stderr string, err error) {
 	stdout = strings.TrimSpace(string(outbuf))
 
 	if err != nil {
-		if exitErr, isExitError := err.(*exec.ExitError); isExitError {
+		exitErr := &exec.ExitError{}
+		if errors.As(err, &exitErr) {
 			stderr = strings.TrimSpace(string(exitErr.Stderr))
 		}
 	}

+ 1 - 1
pkg/settings/pacman.go

@@ -20,7 +20,7 @@ func RetrievePacmanConfig(cmdArgs *parser.Arguments, pacmanConfigPath string) (*
 	if err != nil {
 		cmdErr := err
 		if stderr != "" {
-			cmdErr = fmt.Errorf("%s\n%s", err, stderr)
+			cmdErr = fmt.Errorf("%w\n%s", err, stderr)
 		}
 
 		return nil, false, cmdErr

+ 1 - 1
pkg/upgrade/sources_test.go

@@ -164,7 +164,7 @@ func Test_upDevel(t *testing.T) {
 		tt := tt
 		t.Run(tt.name, func(t *testing.T) {
 			t.Parallel()
-			got := UpDevel(context.TODO(), tt.args.remote, tt.args.aurdata, tt.args.cached)
+			got := UpDevel(context.Background(), tt.args.remote, tt.args.aurdata, tt.args.cached)
 			assert.ElementsMatch(t, tt.want.Up, got.Up)
 		})
 	}

+ 5 - 3
pkg/vcs/vcs.go

@@ -3,6 +3,7 @@ package vcs
 import (
 	"context"
 	"encoding/json"
+	"errors"
 	"fmt"
 	"os"
 	"os/exec"
@@ -81,7 +82,8 @@ func (v *InfoStore) getCommit(ctx context.Context, url, branch string, protocols
 
 		stdout, _, err := v.CmdBuilder.Capture(cmd)
 		if err != nil {
-			if exiterr, ok := err.(*exec.ExitError); ok && exiterr.ExitCode() == 128 {
+			exitError := &exec.ExitError{}
+			if ok := errors.As(err, &exitError); ok && exitError.ExitCode() == 128 {
 				text.Warnln(gotext.Get("devel check for package failed: '%s' encountered an error", cmd.String()))
 				return ""
 			}
@@ -298,7 +300,7 @@ func (v *InfoStore) RemovePackage(pkgs []string) {
 func (v *InfoStore) Load() error {
 	vfile, err := os.Open(v.FilePath)
 	if !os.IsNotExist(err) && err != nil {
-		return fmt.Errorf("failed to open vcs file '%s': %s", v.FilePath, err)
+		return fmt.Errorf("failed to open vcs file '%s': %w", v.FilePath, err)
 	}
 
 	defer vfile.Close()
@@ -306,7 +308,7 @@ func (v *InfoStore) Load() error {
 	if !os.IsNotExist(err) {
 		decoder := json.NewDecoder(vfile)
 		if err = decoder.Decode(&v.OriginsByPackage); err != nil {
-			return fmt.Errorf("failed to read vcs '%s': %s", v.FilePath, err)
+			return fmt.Errorf("failed to read vcs '%s': %w", v.FilePath, err)
 		}
 	}
 

+ 2 - 2
pkg/vcs/vcs_test.go

@@ -356,7 +356,7 @@ func TestInfoStore_NeedsUpdate(t *testing.T) {
 			v := &InfoStore{
 				CmdBuilder: tt.fields.CmdBuilder,
 			}
-			got := v.needsUpdate(context.TODO(), tt.args.infos)
+			got := v.needsUpdate(context.Background(), tt.args.infos)
 			assert.Equal(t, tt.want, got)
 		})
 	}
@@ -407,7 +407,7 @@ func TestInfoStore_Update(t *testing.T) {
 				CmdBuilder:       tt.fields.CmdBuilder,
 			}
 
-			v.Update(context.TODO(), tt.args.pkgName, tt.args.sources)
+			v.Update(context.Background(), tt.args.pkgName, tt.args.sources)
 			assert.Len(t, tt.fields.OriginsByPackage, 1)
 
 			marshalledinfo, err := json.MarshalIndent(tt.fields.OriginsByPackage, "", "\t")