Permalink
Browse files

Declare (*net/http.Request).WithContext as pure

Closes gh-69
  • Loading branch information...
1 parent 78c996f commit 34cb9e1c04508c1fc4d12a65943aa17531909373 @dominikh committed Jan 5, 2017
Showing with 13 additions and 2 deletions.
  1. +2 −0 lint.go
  2. +11 −2 testdata/CheckPureFunctions.go
View
@@ -64,6 +64,8 @@ var stdlibDescs = map[string]Function{
"strings.TrimRightFunc": Function{Pure: true},
"strings.TrimSpace": Function{Pure: true},
"strings.TrimSuffix": Function{Pure: true},
+
+ "(*net/http.Request).WithContext": Function{Pure: true},
}
type FunctionDescriptions map[string]Function
@@ -1,13 +1,22 @@
package pkg
-import "strings"
+import (
+ "context"
+ "net/http"
+ "strings"
+)
-func fn() {
+func fn1() {
strings.Replace("", "", "", 1) // MATCH /is a pure function but its return value is ignored/
foo(1, 2) // MATCH /is a pure function but its return value is ignored/
bar(1, 2)
}
+func fn2() {
+ r, _ := http.NewRequest("GET", "/", nil)
+ r.WithContext(context.Background()) // MATCH /is a pure function but its return value is ignored/
+}
+
func foo(a, b int) int { return a + b }
func bar(a, b int) int {
println(a + b)

0 comments on commit 34cb9e1

Please sign in to comment.