linter: enable wastedassign

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
Valentin Rothberg 2022-03-21 13:44:09 +01:00
parent 070e401499
commit bb6b69b4ab
11 changed files with 15 additions and 17 deletions

View File

@ -65,7 +65,6 @@ linters:
- errchkjson
- maintidx
- nilerr
- wastedassign
- nilnil
linters-settings:
errcheck:

View File

@ -721,7 +721,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
"Optional parent cgroup for the container",
)
_ = cmd.RegisterFlagCompletionFunc(cgroupParentFlagName, completion.AutocompleteDefault)
conmonPidfileFlagName := ""
var conmonPidfileFlagName string
if !isInfra {
conmonPidfileFlagName = "conmon-pidfile"
} else {
@ -734,7 +734,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
)
_ = cmd.RegisterFlagCompletionFunc(conmonPidfileFlagName, completion.AutocompleteDefault)
entrypointFlagName := ""
var entrypointFlagName string
if !isInfra {
entrypointFlagName = "entrypoint"
} else {

View File

@ -58,9 +58,8 @@ func clone(cmd *cobra.Command, args []string) error {
case 3:
ctrClone.CreateOpts.Name = args[1]
ctrClone.Image = args[2]
rawImageName := ""
if !cliVals.RootFS {
rawImageName = args[0]
rawImageName := args[0]
name, err := PullImage(ctrClone.Image, ctrClone.CreateOpts)
if err != nil {
return err

View File

@ -375,7 +375,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
}
}
cleanTmpFile := false
var cleanTmpFile bool
flags.Authfile, cleanTmpFile = buildahUtil.MirrorToTempFileIfPathIsDescriptor(flags.Authfile)
if cleanTmpFile {
defer os.Remove(flags.Authfile)
@ -474,7 +474,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
return nil, err
}
format := ""
var format string
flags.Format = strings.ToLower(flags.Format)
switch {
case strings.HasPrefix(flags.Format, buildahDefine.OCI):

View File

@ -105,7 +105,7 @@ func scp(cmd *cobra.Command, args []string) (finalErr error) {
}
locations := []*entities.ImageScpOptions{}
cliConnections := []string{}
flipConnections := false
var flipConnections bool
for _, arg := range args {
loc, connect, err := parseImageSCPArg(arg)
if err != nil {
@ -233,7 +233,7 @@ func loadToRemote(localFile string, tag string, url *urlP.URL, iden string) (str
errOut := strconv.Itoa(int(n)) + " Bytes copied before error"
return " ", errors.Wrapf(err, errOut)
}
run := ""
var run string
if tag != "" {
return "", errors.Wrapf(define.ErrInvalidArg, "Renaming of an image is currently not supported")
}

View File

@ -105,7 +105,7 @@ func searchFlags(cmd *cobra.Command) {
// imageSearch implements the command for searching images.
func imageSearch(cmd *cobra.Command, args []string) error {
searchTerm := ""
var searchTerm string
switch len(args) {
case 1:
searchTerm = args[0]

View File

@ -1596,7 +1596,7 @@ func readConmonPipeData(runtimeName string, pipe *os.File, ociLog string) (int,
ch <- syncStruct{si: si}
}()
data := -1
data := -1 //nolint: wastedassign
select {
case ss := <-ch:
if ss.err != nil {

View File

@ -262,8 +262,8 @@ func addDevice(g *generate.Generator, device string) error {
// ParseDevice parses device mapping string to a src, dest & permissions string
func ParseDevice(device string) (string, string, string, error) { //nolint
src := ""
dst := ""
var src string
var dst string
permissions := "rwm"
arr := strings.Split(device, ":")
switch len(arr) {

View File

@ -847,7 +847,8 @@ func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, start
if len(cmdArr) == 0 {
return nil, errors.New("Must define a healthcheck command for all healthchecks")
}
concat := ""
var concat string
if cmdArr[0] == "CMD" || cmdArr[0] == "none" { // this is for compat, we are already split properly for most compat cases
cmdArr = strings.Fields(inCmd)
} else if cmdArr[0] != "CMD-SHELL" { // this is for podman side of things, won't contain the keywords

View File

@ -24,7 +24,6 @@ func IsSystemdSessionValid(uid int) bool {
if rootless.IsRootless() {
conn, err = GetLogindConnection(rootless.GetRootlessUID())
object = conn.Object(dbusDest, godbus.ObjectPath(dbusPath))
if err != nil {
//unable to fetch systemd object for logind
logrus.Debugf("systemd-logind: %s", err)

View File

@ -51,10 +51,10 @@ func Split(src string) (entries []string) {
}
entries = []string{}
var runes [][]rune
lastClass := 0
class := 0
var lastClass int
// split into fields based on class of unicode character
for _, r := range src {
var class int
switch {
case unicode.IsLower(r):
class = 1