Skip to content

Commit

Permalink
checkers: add draw.Draw to draw.DrawMask checker (#904)
Browse files Browse the repository at this point in the history
Fixes #819
  • Loading branch information
Sergey Fedchenko committed Feb 20, 2020
1 parent 5714434 commit 0d5eff4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
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

0 comments on commit 0d5eff4

Please sign in to comment.