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

add draw.Draw to draw.DrawMask checker #904

Merged
merged 1 commit into from Feb 20, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions checkers/testdata/wrapperFunc/negative_tests.go
Expand Up @@ -2,12 +2,14 @@ package checker_test

import (
"bytes"
"image"
"image/draw"
"net/http"
"strings"
"sync"
)

func appliedSuggestions(s string, b []byte) {
func appliedSuggestions(s string, b []byte, i draw.Image, r image.Rectangle, p image.Point, o draw.Op) {
var wg sync.WaitGroup
wg.Done()
wg.Add(1)
Expand All @@ -28,9 +30,11 @@ func appliedSuggestions(s string, b []byte) {
bytes.ReplaceAll(b, b, b)

_ = http.NotFoundHandler()

draw.Draw(i, r, i, p, o)
}

func nonMatchingArgs(s string, b []byte) {
func nonMatchingArgs(s string, b []byte, i draw.Image, r image.Rectangle, p image.Point, o draw.Op) {
var wg sync.WaitGroup
wg.Add(1)

Expand All @@ -45,4 +49,6 @@ func nonMatchingArgs(s string, b []byte) {
bytes.Replace(b, b, b, 1)

_ = http.HandlerFunc(nil)

draw.DrawMask(i, r, i, p, i, image.Point{}, o)
}
7 changes: 6 additions & 1 deletion checkers/testdata/wrapperFunc/positive_tests.go
Expand Up @@ -2,13 +2,15 @@ package checker_test

import (
"bytes"
"image"
"image/draw"
"net/http"
"strings"
"sync"
"unicode"
)

func f(s string, b []byte) {
func f(s string, b []byte, i draw.Image, r image.Rectangle, p image.Point, o draw.Op) {
var wg sync.WaitGroup
/*! use WaitGroup.Done method in `wg.Add(-1)` */
wg.Add(-1)
Expand Down Expand Up @@ -41,4 +43,7 @@ func f(s string, b []byte) {

/*! use http.NotFoundHandler method in `http.HandlerFunc(http.NotFound)` */
_ = http.HandlerFunc(http.NotFound)

/*! use draw.Draw method in `draw.DrawMask(i, r, i, p, nil, image.Point{}, o)` */
draw.DrawMask(i, r, i, p, nil, image.Point{}, o)
}
5 changes: 5 additions & 0 deletions checkers/wrapperFunc_checker.go
Expand Up @@ -81,6 +81,11 @@ func init() {
"bytes.Map => bytes.ToTitle": {
{0, "unicode.ToTitle"},
},

"draw.DrawMask => draw.Draw": {
{4, "nil"},
{5, "image.Point{}"},
},
}

matchers := make(map[string]*matcher)
Expand Down