Skip to content
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

cmd/vet: report printf calls with non-const format and no args #60529

Closed
adonovan opened this issue May 31, 2023 · 33 comments
Closed

cmd/vet: report printf calls with non-const format and no args #60529

adonovan opened this issue May 31, 2023 · 33 comments
Assignees
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) gopls/analysis Issues related to running analysis in gopls help wanted NeedsFix The path to resolution is known, but the work has not been done. Proposal Proposal-Accepted release-blocker
Milestone

Comments

@adonovan
Copy link
Member

adonovan commented May 31, 2023

A common mistake not caught by the existing printf vet checker is Printf(v), where v is a variable, when the user intended Printf("%s", v). If the value of v contains an unexpected percent sign, the program has a bug.

I feel like I see this mistake in Google Go readability reviews at least once a week, and the Google corpus shows up hundreds of violations with what looks like close to 100% precision:
https://source.corp.google.com/search?q=%5B.%5DPrintf%5C(%5Ba-z%5D*%5C)%20lang:go&sq=
(Apologies, link to Google internal service.)

Printf and similar functions are usually called with a literal format string, followed by zero or more arguments. Occasionally the format string argument is a variable, either because preceding logic chooses between two alternative formats, or because the call appears in a wrapper function that takes both the format and its arguments as parameters, but in both those cases the format is followed by other arguments. It's hard to imagine any good reason one would call printf with a variable format string and no arguments.

We should make the printf checker report this error.

@timothy-king @findleyr

@adonovan adonovan added help wanted gopls/analysis Issues related to running analysis in gopls Analysis Issues related to static analysis (vet, x/tools/go/analysis) labels May 31, 2023
@adonovan
Copy link
Member Author

adonovan commented May 31, 2023

It's hard to imagine any good reason one would call printf with a variable format string and no arguments.

Ok, I imagined one (having found https://github.com/golang/tools/blob/master/gopls/internal/lsp/cache/load.go#L378):
you want to call a printf wrapper function such as fmt.Errorf with a choice of two format strings both of which you know are percent-free, and there is no non-Printf variant ("fmt.Error") of the function in question.

var msg string
if cond {
    msg = "percent-free error message a"
} else {
    msg = "percent-free error message b"
}
return fmt.Errorf(msg)

The code would be improved by calling fmt.Errorf("%s", msg), since it would be safer in the face of later changes to the logic that assigns msg, but it's not actually wrong.

@robpike
Copy link
Contributor

robpike commented May 31, 2023

The technique you're forbidding is used to generate messages in different languages:

greet := map[string]string{ "en": "hello", "fr": "bonjour"}
fmt.Printf(greet[lang])

(In fact, the $[1] notation is there precisely for the general form of this when word order can vary between languages.)

I realize in this case you're arguing for the case with zero arguments, and my example is a bit contrived that way, but still, to me it feels too useful a technique to be forbidden outright. And there are other ways to do this, of course. Yet, one person's bad code is another's useful technique.

@ianlancetaylor
Copy link
Member

@robpike Sorry, I'm not sure I understand your example. The proposed checker wouldn't report anything for that code.
And wouldn't that use fmt.Println, not fmt.Printf?

@findleyr
Copy link
Member

findleyr commented May 31, 2023

I guess the question is whether it should be OK to use fmt.Printf when fmt.Print would do. By comparison, it is generally accepted that fmt.Errorf is OK to use instead of errors.New even when there are no formatted arguments. Of course, that is typically with a constant error string.

I am not sure if this rule should be applied to Printf wrappers (as with other checks in the printf analyzer). Often Printf wrappers have no corresponding Print wrapper alternative. EDIT: of course the user could always convert to ...Printf("%s", msg), but may require a lot of code to be updated.

@mknyszek mknyszek added this to the Backlog milestone May 31, 2023
@mknyszek mknyszek added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label May 31, 2023
@robpike
Copy link
Contributor

robpike commented Jun 1, 2023

@robpike Sorry, I'm not sure I understand your example. The proposed checker wouldn't report anything for that code. And wouldn't that use fmt.Println, not fmt.Printf?

Sorry, editing mistake. Example updated to drop the user name. And yes, you could use Println instead, but @findleyr gets to the nub: Do we force (through vet) people to use a different printer when there are no arguments? That's really what this is about.

@timothy-king
Copy link
Contributor

If the value of v contains an unexpected percent sign, the program has a bug.

If we know "v" contains a verb this is clearly a bug. Maybe it is okay to warn if v may conditionally contain a verb?

I feel like I see this mistake in Google Go readability reviews at least once a week, and the Google corpus shows up hundreds of violations with what looks like close to 100% precision:

For the handful I have looked at (~5), I am a bit wishy-washy on whether these are buggy. This particular pattern seems common:

        msg := fmt.Sprintf(format, args...)
	// do something else with msg
	logger.Printf(msg)

Printf("%s", msg) or Print does seem like what is intended the examples I have seen. To know that this is bug though seems to require knowing about args, which is often out of scope.

(Another example I have seen is when msg is a constant. The existing checker should already work IIUC.)

@adonovan
Copy link
Member Author

adonovan commented Apr 8, 2024

To know that this is bug though seems to require knowing about args, which is often out of scope.

That's true, but in all the examples I've looked it, it requires knowledge of a non-local and undocumented invariant that the args are percent-free.

I would usually run a measurement over the module mirror corpus and then analyze the rate of true and false positives, but a quick experiment on a single repo (kubernetes) turned up plenty of findings, nearly all bugs.

Here's the new logic:

tools$ git diff
diff --git a/go/analysis/passes/printf/printf.go b/go/analysis/passes/printf/printf.go
index 3235019258..a0ecc5d2eb 100644
--- a/go/analysis/passes/printf/printf.go
+++ b/go/analysis/passes/printf/printf.go
@@ -536,6 +536,18 @@ type formatState struct {
 
 // checkPrintf checks a call to a formatted print routine such as Printf.
 func checkPrintf(pass *analysis.Pass, kind Kind, call *ast.CallExpr, fn *types.Func) {
+       // Calls to fmt.Printf(msg), with a non-constant
+       // format string and no arguments, seem to be a common
+       // mistake.
+       if len(call.Args) == 1 && pass.TypesInfo.Types[call.Args[0]].Value == nil {
+               pass.Reportf(call.Lparen,
+                       "non-constant format string in call to %s (did you mean %s(\"%%s\", %s)?)",
+                       fn.FullName(),
+                       fn.Name(),
+                       analysisutil.Format(pass.Fset, call.Args[0]))
+               return
+       }
+

And here are a random 25 of its 182 findings:

https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/controller/statefulset/stateful_set_test.go#L894: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", onPolicy("Expected set to stay at two replicas"))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/controller/volume/expand/expand_controller.go#L266: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", errorMsg)?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/secret/secret.go#L286: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", errMsg)?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/test/e2e_node/util_sriov.go#L47: non-constant format string in call to k8s.io/kubernetes/test/e2e/framework/skipper.Skipf (did you mean Skipf("%s", msg)?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/test/images/agnhost/crd-conversion-webhook/converter/framework.go#L129: non-constant format string in call to k8s.io/klog/v2.Errorf (did you mean Errorf("%s", msg)?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/controller/nodelifecycle/node_lifecycle_controller_test.go#L2562: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/test/e2e/framework/statefulset/rest.go#L53: non-constant format string in call to fmt.Sprintf (did you mean Sprintf("%s", "creating " + ss.Name + " service")?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/util/operationexecutor/operation_generator.go#L1610: non-constant format string in call to k8s.io/klog/v2.Warningf (did you mean Warningf("%s", volumeToDetach.GenerateMsgDetailed("Node not found on API server. DetachVolume will skip safe to detach check", ""))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/downwardapi/downwardapi_test.go#L361: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/csi/csi_block.go#L411: non-constant format string in call to (k8s.io/klog/v2.Verbose).Infof (did you mean Infof("%s", log("blockMapper.unpublishVolumeForBlock NodeUnpublished successfully [%s]", publishPath))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/csi/csi_block.go#L215: non-constant format string in call to (k8s.io/klog/v2.Verbose).Infof (did you mean Infof("%s", log("blockMapper.publishVolumeForBlock called"))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/controller/statefulset/stateful_set_test.go#L891: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", onPolicy("Could not get scaled down StatefulSet: %v", err))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/test/integration/garbagecollector/garbage_collector_test.go#L698: non-constant format string in call to (*testing.common).Fatalf (did you mean Fatalf("%s", errString)?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/test/e2e/upgrades/apps/etcd.go#L149: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", string(b))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/util/operationexecutor/operation_generator.go#L831: non-constant format string in call to k8s.io/klog/v2.Errorf (did you mean Errorf("%s", volumeToMount.GenerateErrorDetailed("MountVolume.MarkVolumeMountAsUncertain failed", t).Error())?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/test/e2e/windows/gmsa_full.go#L194: non-constant format string in call to k8s.io/kubernetes/test/e2e/framework.Failf (did you mean Failf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/csi/csi_block.go#L140: non-constant format string in call to (k8s.io/klog/v2.Verbose).Infof (did you mean Infof("%s", log("blockMapper.GetPodDeviceMapPath [path=%s; name=%s]", path, m.specName))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/controller/statefulset/stateful_set_test.go#L913: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", onPolicy("Claim ref unexpectedly changed: %v", refs))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/csi/csi_mounter.go#L445: non-constant format string in call to (k8s.io/klog/v2.Verbose).Infof (did you mean Infof("%s", log("Unmounter.TearDownAt successfully unmounted dir [%s]", dir))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/csi/csi_plugin.go#L842: non-constant format string in call to (k8s.io/klog/v2.Verbose).Infof (did you mean Infof("%s", log("CSIDriver %q not found, not adding pod information", driverName))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/util/operationexecutor/operation_generator.go#L1239: non-constant format string in call to k8s.io/klog/v2.Errorf (did you mean Errorf("%s", volumeToMount.GenerateErrorDetailed("MountVolume.MarkVolumeMountAsUncertain failed", err).Error())?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/util/operationexecutor/operation_generator.go#L1467: non-constant format string in call to k8s.io/klog/v2.Infof (did you mean Infof("%s", deviceToDetach.GenerateMsgDetailed("UnmapDevice succeeded", ""))?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/volume/util/operationexecutor/operation_executor.go#L367: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", detailedMsg)?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/controller/podautoscaler/horizontal.go#L416: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", errMsg)?)
https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/controller/statefulset/stateful_set_test.go#L903: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", onPolicy("Unexpected change to condemned pvc ownerRefs: %v", refs))?)

All but one are true positives: bugs (sometimes more than one in the same call!). The one false positive was of the form:

var s = "benign"
fmt.Printf(s)

So that's a 96% success rate.

@adonovan adonovan changed the title cmd/vet: printf: report calls to printf(format) with variable format and no arguments proposal: cmd/vet: printf: report calls to printf(format) with variable format and no arguments Apr 8, 2024
@adonovan adonovan moved this to Incoming in Proposals Apr 8, 2024
@timothy-king
Copy link
Contributor

I was looking into https://go-mod-viewer.appspot.com/k8s.io/[email protected]/pkg/controller/statefulset/stateful_set_test.go#L891: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", onPolicy("Could not get scaled down StatefulSet: %v", err))?)

   834  		onPolicy := func(msg string, args ...interface{}) string {
   835  			return fmt.Sprintf(fmt.Sprintf("(%s) %s", policy, msg), args...)
   836  		}
   ...
   891  			t.Errorf(onPolicy("Could not get scaled down StatefulSet: %v", err))

The diagnostic given on t.Errorf seems correct to me. Should be t.Error. (Diagnostic should maybe say that.) The outer fmt.Sprintf(...) is debatable though. The intention here is to copy the %v from msg and use it as a formatting string. This is debatable style, but it should work. Just kinda interesting that something immediately adjacent to the example illustrated something that should not be warned on. This example would not be warned on due to len(call.Args) == 1.

@timothy-king
Copy link
Contributor

+       if len(call.Args) == 1 && pass.TypesInfo.Types[call.Args[0]].Value == nil {

call.Args[0] could be a function call. We should also check that if call.Args[0]'s type is a tuple, that it is 1 element.

@adonovan
Copy link
Member Author

adonovan commented Apr 9, 2024

The outer fmt.Sprintf(...) is debatable though. The intention here is to copy the %v from msg and use it as a formatting string. This is debatable style, but it should work.

The code assumes that that the result of applying %s to policy (i.e. calling the String method of StatefulSetPersistentVolumeClaimRetentionPolicy, a protocol message) is percent-free. In this particular test, that is true, but in general, the string of this type contains arbitrary characters, and would cause this formatting to fail. So I would describe this as a latent bug just waiting for someone to add a new row to the test table.

Just kinda interesting that something immediately adjacent to the example illustrated something that should not be warned on. This example would not be warned on due to len(call.Args) == 1.

Yes, the lesson is that non-const formats are often a mistake for any value of len(Args), but they are nearly always a mistake for len(Args)=0.

@rsc rsc changed the title proposal: cmd/vet: printf: report calls to printf(format) with variable format and no arguments proposal: cmd/vet: report printf calls with non-const format and no args Apr 10, 2024
@rsc
Copy link
Contributor

rsc commented Apr 10, 2024

Side note but please do not add "did you mean" to error messages. Report the problem, then stop.

@rsc
Copy link
Contributor

rsc commented Apr 10, 2024

This proposal has been added to the active column of the proposals project
and will now be reviewed at the weekly proposal review meetings.
— rsc for the proposal review group

@rsc rsc moved this from Incoming to Active in Proposals Apr 10, 2024
@rsc
Copy link
Contributor

rsc commented Apr 24, 2024

The Kubernetes results definitely look like mostly/all bugs, but we should try more of the ecosystem to estimate the false positive rate. Thanks.

@dominikh
Copy link
Member

Note that this corresponds to Staticcheck's SA1006, which might skew your estimates.

@adonovan
Copy link
Member Author

Running across a sample of 13,000 modules in the module mirror corpus, I got about 50,000 unique diagnostics in 3847 modules. Below are 100 diagnostics selected at random. I sampled a couple dozen and all looked like latent bugs.

https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/mysql/configuration_variables.go#L393: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/disasterrecovery/start_drill_precheck_execution_option_details.go#L41: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/networkloadbalancer/list_backends_request_response.go#L97: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/databasemigration/update_golden_gate_hub.go#L53: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/janelia-flyem/[email protected]/dvid/log_local.go#L83: non-constant format string in call to log.Printf (did you mean Printf("%s", " CRITICAL " + s)?)
https://go-mod-viewer.appspot.com/github.com/lino-network/[email protected]/x/reputation/repv2/reputation.go#L73: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", "failed to marshal json for " + file + " due to " + err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/datasafe/profile_aggregation.go#L46: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/lockbox/access_request_ext.go#L97: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/useflyent/[email protected]/example_client_test.go#L218: non-constant format string in call to (*testing.common).Fatalf (did you mean Fatalf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/datasafe/security_policy_deployment.go#L78: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/go-kratos/[email protected]/pkg/naming/zookeeper/zookeeper.go#L234: non-constant format string in call to github.com/go-kratos/kratos/pkg/log.Warn (did you mean Warn("%s", fmt.Sprintf("registerPeerServer, fail to Create node:%s. error:(%v)", nodePath, err))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/resourcemanager/delete_stack_request_response.go#L70: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/9fans.net/[email protected]/cmd/acme/internal/edit/ecmd.go#L286: non-constant format string in call to 9fans.net/go/cmd/acme/internal/edit.editerror (did you mean editerror("%s", fmt.Sprintf("%s is a directory", s))?)
https://go-mod-viewer.appspot.com/github.com/terraform-providers/[email protected]/ignition/provider.go#L55: non-constant format string in call to github.com/terraform-providers/terraform-provider-ignition/ignition.debug (did you mean debug("%s", e.String())?)
https://go-mod-viewer.appspot.com/github.com/1and1/[email protected]/baremetal_server_test.go#L443: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", "GetServerIps failed. Error: " + err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/apigateway/list_work_request_errors_request_response.go#L85: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/devops/get_project_request_response.go#L64: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/sch/update_service_connector_request_response.go#L75: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/nosql/index.go#L60: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/servicecatalog/delete_service_catalog_association_request_response.go#L70: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/aws-cloudformation/[email protected]/cfn/encoding/encoding_test.go#L101: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", diff)?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/vault/change_secret_compartment_request_response.go#L84: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/blevesearch/bleve/[email protected]/search/searcher/geoshape_intersects_test.go#L1420: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/github.com/aerospike/aerospike-client-go/[email protected]/internal/lua/lua_aerospike.go#L56: non-constant format string in call to (*github.com/aerospike/aerospike-client-go/v6/logger.logger).Warn (did you mean Warn("%s", str)?)
https://go-mod-viewer.appspot.com/github.com/1and1/[email protected]/baremetal_server_test.go#L198: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", "Starting the server failed. Error: " + err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/databasemanagement/awr_db_snapshot_collection.go#L71: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/opa/create_opa_instance_request_response.go#L71: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/vmware/[email protected]/logical_switching_api.go#L2725: non-constant format string in call to github.com/vmware/go-vmware-nsxt.reportError (did you mean reportError("%s", localVarHttpResponse.Status)?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/datacatalog/metastore_summary.go#L75: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/oda/delete_imported_package_request_response.go#L82: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/resourcemanager/update_stack_details.go#L75: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/networkfirewall/update_security_rule_request_response.go#L77: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/vnmonitoring/update_internet_gateway_details.go#L52: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/servicemesh/list_virtual_services_request_response.go#L97: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/containerengine/persistent_volume_config_details.go#L45: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/networkloadbalancer/work_request_error.go#L43: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/opsi/create_operations_insights_warehouse_request_response.go#L72: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/pulumi/pulumi-kubernetes/sdk/[email protected]/go/kubernetes/auditregistration/v1alpha1/init.go#L38: fmt.Println call has possible Printf formatting directive %v
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/loganalytics/action.go#L78: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/kaspanet/[email protected]/domain/consensus/processes/coinbasemanager/coinbasemanager_test.go#L125: non-constant format string in call to (*testing.common).Logf (did you mean Logf("%s", tableStr)?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/databasemanagement/update_external_db_system_discovery_details.go#L48: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
ID: "command.debug.kv.clean.submit",
https://go-mod-viewer.appspot.com/github.com/particl/[email protected]/hdkeychain/extendedkey_test.go#L235: (*testing.common).Errorf format %d reads arg #1, but call has 0 args
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/oda/skill_parameter_collection.go#L36: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/benthosdev/benthos/[email protected]/internal/impl/kafka/input_sarama_kafka_test.go#L19: non-constant format string in call to github.com/benthosdev/benthos/v4/internal/component/testutil.InputFromYAML (did you mean InputFromYAML("%s", fmt.Sprintf(formatStr, args...))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/database/rotate_pluggable_database_encryption_key_request_response.go#L76: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/nginxinc/[email protected]/internal/nginx/manager.go#L132: non-constant format string in call to (github.com/golang/glog.Verbose).Infof (did you mean Infof("%s", string(content))?)
https://go-mod-viewer.appspot.com/github.com/smugmug/[email protected]/endpoints/query/query_test.go#L40: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", e)?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/keymanagement/schedule_key_version_deletion_request_response.go#L87: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/jms/work_request_resource.go#L51: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/1and1/[email protected]/publicips_test.go#L155: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", "UpdatePublicIp failed. Error: " + err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/vnmonitoring/update_virtual_circuit_details.go#L128: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/matthieudolci/[email protected]/bot/handler.go#L90: non-constant format string in call to fmt.Sprintf (did you mean Sprintf("%s", user.Profile.RealName)?)
However, you should be able to ssh into the machine using the user "ubuntu" and
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/resourcemanager/template_summary.go#L64: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/dataintegration/data_entity_summary_from_data_store.go#L106: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/oda/update_digital_assistant_parameter_details.go#L36: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/ons/notification_topic.go#L73: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/core/create_instance_console_connection_request_response.go#L72: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/go.ligato.io/vpp-agent/[email protected]/plugins/vpp/ifplugin/vppcalls/vpp2101/vmxnet3_vppcalls.go#L68: non-constant format string in call to github.com/pkg/errors.Errorf (did you mean Errorf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/threatintelligence/indicator_source_summary.go#L36: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/waa/create_web_app_acceleration_policy_request_response.go#L70: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/dts/update_appliance_export_job_request_response.go#L72: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/nosql/create_replica_details.go#L54: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/influx6/[email protected]/ntrace/ntrace.go#L113: non-constant format string in call to log.Printf (did you mean Printf("%s", "Closing span, path: " + r.URL.Path)?)
https://go-mod-viewer.appspot.com/mosn.io/[email protected]/pkg/router/routers_manager_test.go#L251: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/networkloadbalancer/update_network_security_groups_details.go#L45: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/databasemanagement/list_sql_tuning_sets_request_response.go#L92: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/datalabelingservicedataplane/annotation_aggregation_dimensions.go#L37: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/tobyzxj/[email protected]/uuid_test.go#L331: (*testing.common).Errorf call has arguments but no formatting directives
https://go-mod-viewer.appspot.com/gosrc.io/[email protected]/stanza/pubsub_owner_test.go#L721: non-constant format string in call to (*testing.common).Fatalf (did you mean Fatalf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/cloudmigrations/get_migration_asset_request_response.go#L64: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/identitydomains/my_support_account_user.go#L103: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/datasafe/profile.go#L122: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/core/ip_sec_connection_tunnel_shared_secret.go#L42: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/cloudbridge/change_agent_compartment_request_response.go#L81: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/apigateway/pem_encoded_public_key.go#L48: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/keybase/client/[email protected]/stellar/bundle/boxer_test.go#L326: non-constant format string in call to (*testing.common).Logf (did you mean Logf("%s", spew.Sdump(boxed))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/datasafe/mask_data_request_response.go#L67: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/monitoring/alarm_override.go#L92: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/go-chi/[email protected]/mux_test.go#L499: non-constant format string in call to (*testing.common).Fatalf (did you mean Fatalf("%s", body)?)
https://go-mod-viewer.appspot.com/github.com/cloudwego/[email protected]/parser/parser.go#L360: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", "unknown rule: " + rul3s[node.pegRule])?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/databasemanagement/get_managed_database_group_request_response.go#L64: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/databasemanagement/update_external_db_system_macs_connector_details.go#L48: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/dataflow/work_request_log.go#L45: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/gcash/[email protected]/bech32/bech32.go#L75: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", "checksum failed. " + moreInfo)?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/artifacts/container_repository_collection.go#L52: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/lockbox/delete_approval_template_request_response.go#L71: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/alexellis/[email protected]/pkg/v2/exec_test.go#L158: non-constant format string in call to (*testing.common).Fatalf (did you mean Fatalf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/dataintegration/update_connection_from_o_auth2.go#L129: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/go-ldap/[email protected]+incompatible/ldap_test.go#L112: non-constant format string in call to (*testing.common).Errorf (did you mean Errorf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/datasafe/audit_policy_dimensions.go#L45: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/identitydomains/extension_posix_group.go#L45: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/bufbuild/[email protected]/grpchealth_test.go#L59: non-constant format string in call to (*testing.common).Fatalf (did you mean Fatalf("%s", err.Error())?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/databasetools/validate_database_tools_connection_oracle_database_result.go#L72: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/ByteArena/[email protected]/DynamicsB2JointRope.go#L289: fmt.Printf format %d has arg joint.M_collideConnected of wrong type bool
https://go-mod-viewer.appspot.com/github.com/okex/[email protected]/libs/tendermint/types/validator_set_test.go#L264: non-constant format string in call to (*testing.common).Fatalf (did you mean Fatalf("%s", fmt.Sprintf("vset.Proposer (%X) does not match expected proposer (%X) for (%d, %d)", got, expected, i, j))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/identitydataplane/claim.go#L42: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/jms/java_artifact.go#L79: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)
https://go-mod-viewer.appspot.com/github.com/oracle/oci-go-sdk/[email protected]/cloudguard/trigger_responder_request_response.go#L81: non-constant format string in call to fmt.Errorf (did you mean Errorf("%s", strings.Join(errMessage, "\n"))?)

@rsc
Copy link
Contributor

rsc commented May 8, 2024

We should drop the 'did you mean' but otherwise it looks like high-quality signal.

@rsc
Copy link
Contributor

rsc commented May 8, 2024

Have all remaining concerns about this proposal been addressed?

The proposal is to report calls to printf-like functions in which the format is a non-constant string and there are no arguments. In the ecosystem these are overwhelmingly misuses where the caller has prepared arguments for a print-like function, not a printf-like function.

@rsc
Copy link
Contributor

rsc commented May 15, 2024

By the way, while we should definitely drop "did you mean" from the analyzer diagnostic text, it would be completely reasonable to make that code a SuggestedFix in the Diagnostic for people using the analyzer in IDEs.

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Sep 16, 2024
mauri870 added a commit to mauri870/elastic-agent-libs that referenced this issue Oct 1, 2024
The cmd/vet in Go 1.24 reports printf calls with non-const format and no
args, causing one test in logp to fail.

See golang/go#60529.

```
$ go install golang.org/dl/gotip@latest
$ gotip download
$ gotip test ./logp -count=1
logp/core_test.go:714:7: non-constant format string in call to github.com/elastic/elastic-agent-libs/logp.Info
FAIL    github.com/elastic/elastic-agent-libs/logp [build failed]
```
mauri870 added a commit to elastic/elastic-agent-libs that referenced this issue Oct 2, 2024
The cmd/vet in Go 1.24 reports printf calls with non-const format and no
args, causing one test in logp to fail.

See golang/go#60529.

```
$ go install golang.org/dl/gotip@latest
$ gotip download
$ gotip test ./logp -count=1
logp/core_test.go:714:7: non-constant format string in call to github.com/elastic/elastic-agent-libs/logp.Info
FAIL    github.com/elastic/elastic-agent-libs/logp [build failed]
```
VihasMakwana pushed a commit to VihasMakwana/elastic-agent-libs that referenced this issue Oct 4, 2024
The cmd/vet in Go 1.24 reports printf calls with non-const format and no
args, causing one test in logp to fail.

See golang/go#60529.

```
$ go install golang.org/dl/gotip@latest
$ gotip download
$ gotip test ./logp -count=1
logp/core_test.go:714:7: non-constant format string in call to github.com/elastic/elastic-agent-libs/logp.Info
FAIL    github.com/elastic/elastic-agent-libs/logp [build failed]
```
dveeden added a commit to dveeden/tidb-tools that referenced this issue Nov 22, 2024
```
$ make GO=gotip build
gotip version
go version devel go1.24-4865aadc Fri Nov 22 05:22:24 2024 +0000 linux/amd64
gofmt (simplify)
vet
dump_region/main.go:59:14: non-constant format string in call to fmt.Printf
pkg/check/privilege.go:146:51: non-constant format string in call to github.com/pingcap/tidb-tools/pkg/check.NewError
pkg/check/table_structure.go:130:19: non-constant format string in call to github.com/pingcap/tidb-tools/pkg/check.NewError
pkg/check/table_structure.go:136:19: non-constant format string in call to github.com/pingcap/tidb-tools/pkg/check.NewError
importer/config.go:73:14: non-constant format string in call to fmt.Printf
make: *** [Makefile:86: check] Error 1
```

Related: golang/go#60529
@dmitshur
Copy link
Contributor

This vet change is new to Go 1.24 and still needs to be mentioned in Go 1.24 release notes, right? Reopening with a release blocker label to track that.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/631682 mentions this issue: doc/next: add release note for vet on Printf(s) with non-const s

stephenfin added a commit to stephenfin/gophercloud that referenced this issue Nov 28, 2024
We were incorrectly using 'fmt.Printf', 'fmt.Errorf' and 't.Logf' with
non-template strings/no arguments. The fix to this is replace these
calls with the non-suffixed variants. There are many users of
'fmt.Fprint' - too many to do by hand - so this replacement was resolved
using 'sed':

  sed 's/Fprintf/Fprint/g' -i $(ag fmt.Fprintf -l)

We then manually fix the 25 cases where 'fmt.Fprintf' is actually
warranted and manually replaced the errant users of 'fmt.Errorf' and
't.Logf'. We also rework 'internal/acceptance/clients/clients.go'
slightly to make the code a bit clearer.

PS: This is apparently going to be an issue in go 1.24 (specifically in
'go vet') [1] so this is not just golangci-lint being annoying.
@pierreprinetti, that's directed at you ;)

[1] golang/go#60529

Signed-off-by: Stephen Finucane <[email protected]>
stephenfin added a commit to stephenfin/gophercloud that referenced this issue Nov 28, 2024
We were incorrectly using 'fmt.Printf', 'fmt.Errorf' and 't.Logf' with
non-template strings/no arguments. The fix to this is replace these
calls with the non-suffixed variants. There are many users of
'fmt.Fprint' - too many to do by hand - so this replacement was resolved
using 'sed':

  sed 's/Fprintf/Fprint/g' -i $(ag fmt.Fprintf -l)

We then manually fix the 25 cases where 'fmt.Fprintf' is actually
warranted and manually replaced the errant users of 'fmt.Errorf' and
't.Logf'. We also rework 'internal/acceptance/clients/clients.go'
slightly to make the code a bit clearer.

PS: This is apparently going to be an issue in go 1.24 (specifically in
'go vet') [1] so this is not just golangci-lint being annoying.
@pierreprinetti, that's directed at you ;)

[1] golang/go#60529

Signed-off-by: Stephen Finucane <[email protected]>
stephenfin added a commit to stephenfin/gophercloud that referenced this issue Nov 29, 2024
We were incorrectly using 'fmt.Printf', 'fmt.Errorf' and 't.Logf' with
non-template strings/no arguments. The fix to this is replace these
calls with the non-suffixed variants. There are many users of
'fmt.Fprint' - too many to do by hand - so this replacement was resolved
using 'sed':

  sed 's/Fprintf/Fprint/g' -i $(ag fmt.Fprintf -l)

We then manually fix the 25 cases where 'fmt.Fprintf' is actually
warranted and manually replaced the errant users of 'fmt.Errorf' and
't.Logf'. We also rework 'internal/acceptance/clients/clients.go'
slightly to make the code a bit clearer.

PS: This is apparently going to be an issue in go 1.24 (specifically in
'go vet') [1] so this is not just golangci-lint being annoying.
@pierreprinetti, that's directed at you ;)

[1] golang/go#60529

Signed-off-by: Stephen Finucane <[email protected]>
stephenfin added a commit to stephenfin/gophercloud that referenced this issue Nov 29, 2024
We were incorrectly using 'fmt.Printf', 'fmt.Errorf' and 't.Logf' with
non-template strings/no arguments. The fix to this is replace these
calls with the non-suffixed variants. There are many users of
'fmt.Fprint' - too many to do by hand - so this replacement was resolved
using 'sed':

  sed 's/Fprintf/Fprint/g' -i $(ag fmt.Fprintf -l)

We then manually fix the 25 cases where 'fmt.Fprintf' is actually
warranted and manually replaced the errant users of 'fmt.Errorf' and
't.Logf'. We also rework 'internal/acceptance/clients/clients.go'
slightly to make the code a bit clearer.

PS: This is apparently going to be an issue in go 1.24 (specifically in
'go vet') [1] so this is not just golangci-lint being annoying.
@pierreprinetti, that's directed at you ;)

[1] golang/go#60529

Signed-off-by: Stephen Finucane <[email protected]>
stephenfin added a commit to stephenfin/gophercloud that referenced this issue Nov 29, 2024
We were incorrectly using 'fmt.Printf', 'fmt.Errorf' and 't.Logf' with
non-template strings/no arguments. The fix to this is replace these
calls with the non-suffixed variants. There are many users of
'fmt.Fprint' - too many to do by hand - so this replacement was resolved
using 'sed':

  sed 's/Fprintf/Fprint/g' -i $(ag fmt.Fprintf -l)

We then manually fix the 25 cases where 'fmt.Fprintf' is actually
warranted and manually replaced the errant users of 'fmt.Errorf' and
't.Logf'. We also rework 'internal/acceptance/clients/clients.go'
slightly to make the code a bit clearer.

PS: This is apparently going to be an issue in go 1.24 (specifically in
'go vet') [1] so this is not just golangci-lint being annoying.
@pierreprinetti, that's directed at you ;)

[1] golang/go#60529

Signed-off-by: Stephen Finucane <[email protected]>
gophercloud-backport-bot bot pushed a commit to gophercloud/gophercloud that referenced this issue Dec 6, 2024
We were incorrectly using 'fmt.Printf', 'fmt.Errorf' and 't.Logf' with
non-template strings/no arguments. The fix to this is replace these
calls with the non-suffixed variants. There are many users of
'fmt.Fprint' - too many to do by hand - so this replacement was resolved
using 'sed':

  sed 's/Fprintf/Fprint/g' -i $(ag fmt.Fprintf -l)

We then manually fix the 25 cases where 'fmt.Fprintf' is actually
warranted and manually replaced the errant users of 'fmt.Errorf' and
't.Logf'. We also rework 'internal/acceptance/clients/clients.go'
slightly to make the code a bit clearer.

PS: This is apparently going to be an issue in go 1.24 (specifically in
'go vet') [1] so this is not just golangci-lint being annoying.
@pierreprinetti, that's directed at you ;)

[1] golang/go#60529

Signed-off-by: Stephen Finucane <[email protected]>
Kesuaheli added a commit to cake4everyone/cake4everybot that referenced this issue Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Analysis Issues related to static analysis (vet, x/tools/go/analysis) gopls/analysis Issues related to running analysis in gopls help wanted NeedsFix The path to resolution is known, but the work has not been done. Proposal Proposal-Accepted release-blocker
Projects
Status: Accepted
Development

No branches or pull requests