Skip to content

Commit

Permalink
checkers: add At() for httpNoBody checker (#1164)
Browse files Browse the repository at this point in the history
  • Loading branch information
quasilyte committed Dec 7, 2021
1 parent e394bba commit 9463ac1
Show file tree
Hide file tree
Showing 3 changed files with 532 additions and 527 deletions.
2 changes: 1 addition & 1 deletion checkers/checkers_test.go
Expand Up @@ -199,7 +199,7 @@ func TestExternal(t *testing.T) {
continue
}
if diff := cmp.Diff(want, have); diff != "" {
t.Errorf("%s output mismatches:\n%s", proj.Name(), diff)
t.Errorf("%s output mismatches (+have -want):\n%s", proj.Name(), diff)
continue
}
}
Expand Down
6 changes: 4 additions & 2 deletions checkers/rules/rules.go
Expand Up @@ -118,12 +118,14 @@ func httpNoBody(m dsl.Matcher) {
m.Match("http.NewRequest($method, $url, $nil)").
Where(m["nil"].Text == "nil").
Suggest("http.NewRequest($method, $url, http.NoBody)").
Report("http.NoBody should be preferred to the nil request body")
Report("http.NoBody should be preferred to the nil request body").
At(m["nil"])

m.Match("http.NewRequestWithContext($ctx, $method, $url, $nil)").
Where(m["nil"].Text == "nil").
Suggest("http.NewRequestWithContext($ctx, $method, $url, http.NoBody)").
Report("http.NoBody should be preferred to the nil request body")
Report("http.NoBody should be preferred to the nil request body").
At(m["nil"])
}

//doc:summary Detects expressions like []rune(s)[0] that may cause unwanted rune slice allocation
Expand Down

0 comments on commit 9463ac1

Please sign in to comment.