Skip to content

Commit

Permalink
rename function literal to anonymous function to be more understandable
Browse files Browse the repository at this point in the history
  • Loading branch information
vankleefjim authored and sivchari committed Jun 15, 2022
1 parent cc152e3 commit 11f2e17
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tenv.go
Expand Up @@ -63,7 +63,7 @@ func checkFuncLit(pass *analysis.Pass, f *ast.FuncLit, fileName string) {
if !ok {
return
}
checkStmts(pass, f.Body.List, "function literal", argName)
checkStmts(pass, f.Body.List, "anonymous function", argName)
}

func checkStmts(pass *analysis.Pass, stmts []ast.Stmt, funcName, argName string) {
Expand Down
6 changes: 3 additions & 3 deletions testdata/src/a/a_test.go
Expand Up @@ -59,10 +59,10 @@ func FuzzF(f *testing.F) {
func TestFunctionLiteral(t *testing.T) {
testsetup()
t.Run("test", func(t *testing.T) {
os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in function literal"
err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in function literal"
os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in anonymous function"
err := os.Setenv("a", "b") // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in anonymous function"
_ = err
if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in function literal"
if err := os.Setenv("a", "b"); err != nil { // want "os\\.Setenv\\(\\) can be replaced by `t\\.Setenv\\(\\)` in anonymous function"
_ = err
}
})
Expand Down

0 comments on commit 11f2e17

Please sign in to comment.