cmd/initContainer, cmd/run: Restore hints about unreachable code

In the past, before commit d323143c46, there was either had a
dummy 'return' statement or a self-documenting 'panic' that said that
the code should not be reached.  Since neither golangci-lint nor
'go vet' likes those, a comment is the only option left.

Note that the core Go tools like 'go vet' [1], but also 'go lint' [2],
explicitly don't intend to add fine-grained configuration options,
including inline directives or pragmas, to silence specific warnings.
That's something golangci-lint offers [3], to the extent that it's
supported by its linters [4].  However, golangci-lint also uses 'go vet'
as one of those linters, so it's the same problem all over again.

Therefore, between the two extremes of leaving the code difficult to
read and using a very big hammer to disable a needlessly big chuck of
'go vet', a comment is the least worst option.

[1] https://github.com/golang/go/issues/17058
    https://github.com/golang/go/issues/18432

[2] https://github.com/golang/lint/issues/263

[3] https://golangci-lint.run/usage/false-positives/

[4] https://golangci-lint.run/usage/linters/

Fallout from d323143c46

https://github.com/containers/toolbox/pull/1185
This commit is contained in:
Debarshi Ray 2022-11-30 22:07:13 +01:00
parent d0fe8c45f7
commit b85ab0a4f1
2 changed files with 4 additions and 0 deletions

View file

@ -361,6 +361,8 @@ func initContainer(cmd *cobra.Command, args []string) error {
logrus.Warnf("Received an error from the file system watcher: %v", err)
}
}
// code should not be reached
}
func initContainerHelp(cmd *cobra.Command, args []string) {

View file

@ -409,6 +409,8 @@ func runCommandWithFallbacks(container string,
return &exitError{exitCode, nil}
}
}
// code should not be reached
}
func runHelp(cmd *cobra.Command, args []string) {