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

workflowcheck: mark some fmt functions as deterministic #1038

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions contrib/tools/workflowcheck/determinism/ident_refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ var DefaultIdentRefs = IdentRefs{
// We mark these as deterministic since they give so many false positives
"(reflect.Value).Interface": false,
"runtime.Caller": false,
"fmt.Append": false,
"fmt.Appendf": false,
"fmt.Appendln": false,
"fmt.Errorf": false,
"fmt.Sprintf": false,
"fmt.Sprint": false,
"fmt.Sprintln": false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May want to add each of these being called in a method in contrib/tools/workflowcheck/determinism/testdata/src/a/calls.go but not that big of a deal.

Also, may want to add the Append and Sscan funcs here too

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, just for peace of mind, can we add the following to the bottom of contrib/tools/workflowcheck/determinism/testdata/src/a/calls.go:

func SafeFmtCall() {
	fmt.Sprintf("foo bar")
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

"fmt.Sscan": false,
"fmt.Sscanf": false,
"fmt.Sscanln": false,
// We are considering the global pseudorandom as non-deterministic by default
// since it's global (even if they set a seed), but we allow use of a manually
// instantiated random instance that may have a localized, fixed seed
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package a

import (
"fmt"
"log"
mathrand "math/rand"
"net/http"
Expand Down Expand Up @@ -57,3 +58,7 @@ func CallsMathRandom() { // want CallsMathRandom:"calls non-deterministic functi
func CallsHTTP() { // want CallsHTTP:"calls non-deterministic function net/http.Get"
http.Get("http://example.com")
}

func SafeFmtCall() {
fmt.Sprintf("foo bar")
}