diff --git a/README.md b/README.md index b1c6380b..faeb6fb0 100644 --- a/README.md +++ b/README.md @@ -465,19 +465,29 @@ disable this feature, use `--formatter.check-format-string=false` flag. #### 3) -Requirement of the f-assertions if format string is used. Disabled by default, use `--formatter.require-f-funcs` flag -to enable. This helps follow Go's implicit convention +Requirement of the f-assertions (e.g. assert.Equal**f**) if format string is used. Disabled by default, use +`--formatter.require-f-funcs` flag to enable.
-> Printf-like functions must end with `f` +This helps follow Go's implicit convention _"Printf-like functions must end with `f`"_ and sets the stage for moving to +`v2` of `testify`. In this way the checker resembles the [goprintffuncname](https://github.com/jirfag/go-printf-func-name) +linter (included in [golangci-lint](https://golangci-lint.run/usage/linters/)).
-and sets the stage for moving to `v2` of `testify`. In this way the checker resembles the -[goprintffuncname](https://github.com/jirfag/go-printf-func-name) linter (included in -[golangci-lint](https://golangci-lint.run/usage/linters/)). Also format string in f-assertions is highlighted by IDE -, e.g. GoLand: +Also, verbs in the format string of f-assertions are highlighted by an IDE, e.g. GoLand: F-assertion IDE highlighting -#### Historical Reference +
+ +> [!CAUTION] +> `--formatter.require-f-funcs` requires f-assertions **even if there are no variable-length variables**, i.e. it +> requires `require.NoErrorf` for both these cases: +> ``` +> require.NoErrorf(t, err, "unexpected error") +> require.NoErrorf(t, err, "unexpected error for sid: %v", sid) +> ``` +> To understand this behavior, please read the reference below. + +#### Historical reference of formatter
diff --git a/internal/config/config.go b/internal/config/config.go index a8812e6d..d794465b 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -133,7 +133,7 @@ func BindToFlags(cfg *Config, fs *flag.FlagSet) { "to enable go vet's printf checks") fs.BoolVar(&cfg.Formatter.RequireFFuncs, "formatter.require-f-funcs", false, - "to require f-assertions if format string is used") + "to require f-assertions if format string is used (even if there are no variable-length variables)") fs.BoolVar(&cfg.GoRequire.IgnoreHTTPHandlers, "go-require.ignore-http-handlers", false,