-
-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GO code staticcheck cleanup #1038
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import ( | |
"golang.org/x/text/cases" | ||
"golang.org/x/text/language" | ||
|
||
"github.com/lxc/incus/v6/client" | ||
incus "github.com/lxc/incus/v6/client" | ||
cli "github.com/lxc/incus/v6/internal/cmd" | ||
"github.com/lxc/incus/v6/internal/i18n" | ||
"github.com/lxc/incus/v6/internal/recover" | ||
|
@@ -241,7 +241,8 @@ func (c *cmdAdminRecover) Run(cmd *cobra.Command, args []string) error { | |
// Send /internal/recover/import request to the daemon. | ||
// Don't lint next line with gosimple. It says we should convert reqValidate directly to an RecoverImportPost | ||
// because their types are identical. This is less clear and will not work if either type changes in the future. | ||
reqImport := recover.ImportPost{ //nolint:gosimple | ||
//nolint:all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why turn off all linting? |
||
reqImport := recover.ImportPost{ //lint:ignore S1016 for reason above | ||
Pools: reqValidate.Pools, | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -427,7 +427,9 @@ func instanceCreateAsCopy(s *state.State, opts instanceCreateAsCopyOpts, op *ope | |
"path": "/", | ||
"pool": instRootDiskDevice["pool"], | ||
} | ||
} else { //nolint:staticcheck // (keep the empty branch for the comment) | ||
//nolint:all | ||
//lint:ignore SA9003 keep the empty branch for the comment | ||
} else { //nolint:all | ||
Comment on lines
-430
to
+432
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what's going on here, that change looks off. |
||
// Snapshot has multiple root disk devices, we can't automatically fix this so | ||
// leave alone so we don't prevent copy. | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,10 +26,10 @@ import ( | |
"github.com/lxc/incus/v6/shared/util" | ||
) | ||
|
||
// clusterBusyError is returned by dqlite if attempting attempting to join a cluster at the same time as a role-change. | ||
// errClusterBusy is returned by dqlite if attempting attempting to join a cluster at the same time as a role-change. | ||
// This error tells us we can retry and probably join the cluster or fail due to something else. | ||
// The error code here is SQLITE_BUSY. | ||
var clusterBusyError = fmt.Errorf("A configuration change is already in progress (5)") | ||
var errClusterBusy = fmt.Errorf("A configuration change is already in progress (5)") | ||
|
||
// Bootstrap turns a non-clustered server into the first (and leader) | ||
// member of a new cluster. | ||
|
@@ -447,7 +447,7 @@ func Join(state *state.State, gateway *Gateway, networkCert *localtls.CertInfo, | |
return fmt.Errorf("Failed to join cluster: %w", ctx.Err()) | ||
default: | ||
err = client.Add(ctx, info.NodeInfo) | ||
if err != nil && err.Error() == clusterBusyError.Error() { | ||
if err != nil && err.Error() == errClusterBusy.Error() { | ||
// If the cluster is busy with a role change, sleep a second and then keep trying to join. | ||
time.Sleep(1 * time.Second) | ||
continue | ||
|
@@ -593,6 +593,8 @@ func NotifyHeartbeat(state *state.State, gateway *Gateway) { | |
// Wait for heartbeat to finish and then release. | ||
// Ignore staticcheck "SA2001: empty critical section" because we want to wait for the lock. | ||
gateway.HeartbeatLock.Lock() | ||
//nolint:all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why turn off all linting? |
||
//lint:ignore SA2001 we want to wait for the lock | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment above ( |
||
gateway.HeartbeatLock.Unlock() //nolint:staticcheck | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ func Reset(path string, imports []string, buildComment string, iface bool) error | |
content := fmt.Sprintf(`%spackage %s | ||
|
||
// The code below was generated by %s - DO NOT EDIT! | ||
//lint:file-ignore U1000,SA4006 Ignore staticcheck | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So just because the files are auto-generated doesn't mean that issues/lints aren't worth fixing. It just means that rather than fixing the issues directly in the |
||
|
||
import ( | ||
`, buildComment, os.Getenv("GOPACKAGE"), os.Args[0]) | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// Package response contains helpers for rendering HTTP responses. | ||
// | ||
//nolint:deadcode,unused | ||
//nolint:all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why ignoring all lints? |
||
//lint:file-ignore U1000 Ignore unused | ||
|
||
package response | ||
|
||
import ( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ import ( | |
"github.com/zitadel/oidc/v3/pkg/oidc" | ||
"golang.org/x/crypto/ssh" | ||
|
||
"github.com/lxc/incus/v6/client" | ||
incus "github.com/lxc/incus/v6/client" | ||
"github.com/lxc/incus/v6/shared/api" | ||
"github.com/lxc/incus/v6/shared/util" | ||
) | ||
|
@@ -332,6 +332,8 @@ func (c *Config) getConnectionArgs(name string) (*incus.ConnectionArgs, error) { | |
// Golang has deprecated all methods relating to PEM encryption due to a vulnerability. | ||
// However, the weakness does not make PEM unsafe for our purposes as it pertains to password protection on the | ||
// key file (client.key is only readable to the user in any case), so we'll ignore deprecation. | ||
//nolint:all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why turn off all linting? |
||
//lint:ignore SA1019 see above for reason | ||
isEncrypted := x509.IsEncryptedPEMBlock(pemKey) //nolint:staticcheck | ||
isSSH := pemKey.Type == "OPENSSH PRIVATE KEY" | ||
if isEncrypted || isSSH { | ||
|
@@ -366,6 +368,8 @@ func (c *Config) getConnectionArgs(name string) (*incus.ConnectionArgs, error) { | |
return nil, fmt.Errorf("Unsupported key type: %T", sshKey) | ||
} | ||
} else { | ||
//nolint:all | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why turn off all linting? |
||
//lint:ignore SA1019 see above for reason | ||
derKey, err := x509.DecryptPEMBlock(pemKey, []byte(password)) //nolint:staticcheck | ||
if err != nil { | ||
return nil, err | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you ran goimports or something like that which has a tendency to go mess with our import names, can you remove all of those from your commit?