Skip to content

Releases: jingyugao/rowserrcheck

v1.1.1

27 Oct 10:30
bd4dd44
Compare
Choose a tag to compare

What's Changed

  • Find uses of Rows.Err when Rows is an interface by @coder543 in #23

New Contributors

Full Changelog: 1.1.0...v1.1.1

v1.1.0: follow sql.Rows across ssa.UnOps (#17)

13 May 10:04
d907ca7
Compare
Choose a tag to compare
* rename noCallClose and isCloseCall

These functions look for Err() calls. Now the naming reflects that a
bit better.

* rename getResVal to getRows val

* rename getReqCall to getCallReturnsRow

Signed-off-by: Steven Danna <StevenSDanna@gmail.com>

* rename notCheck to errCallMissing

* remove unused isNamedType function

* reverse logic from errNotCalled to errCalled

I think that this structuring will be a bit eaiser to follow for
future changes.

* remove ineffective append

We only range over this slice once and the append doesn't impact the
range.

* follows sql.Rows across ssa.UnOps

Previously, code such as the following:

```go
rows, err := db.Query("select 1")
if err != nil {
	return err
}
defer func() { _ = rows.Close() }()
for rows.Next() {}
return rows.Err()
```

Would produce a warning despite the clear call to rows.Err(). It
appears this is cause by the fact that the closure around rows.Close()
induces a level of indirection that we could not follow:

```
func issue16() error:
0:                                                                entry P:0 S:2
	t0 = new *database/sql.Rows (rows)                  **database/sql.Rows
	t1 = *db                                               *database/sql.DB
	t2 = (*database/sql.DB).Query(t1, "select 1":string, nil:[]interface{}...) (*database/sql.Rows, error)
	t3 = extract t2 #0                                   *database/sql.Rows
	*t0 = t3
	t4 = extract t2 #1                                                error
	t5 = t4 != nil:error                                               bool
	if t5 goto 1 else 2
1:                                                              if.then P:1 S:0
	rundefers
	return t4
2:                                                              if.done P:1 S:1
	t6 = make closure issue16$1 [t0]                                 func()
	defer t6()
	jump 5
3:                                                              recover P:0 S:0
	return nil:error
4:                                                             for.done P:1 S:0
	t7 = *t0                                             *database/sql.Rows
	t8 = (*database/sql.Rows).Err(t7)                                 error
	rundefers
	return t8
5:                                                             for.loop P:2 S:2
	t9 = *t0                                             *database/sql.Rows
	t10 = (*database/sql.Rows).Next(t9)                                bool
	if t10 goto 5 else 4
```

Fixes #16

* bugfix: fix bad return in run method

```
passes/rowserr/rowserr.go:67:3: too many arguments to return
	have (nil, nil)
	want ()
```

v0.1: follow sql.Rows across ssa.UnOps (#17)

15 Mar 08:59
d907ca7
Compare
Choose a tag to compare

follow sql.Rows across ssa.UnOps (#17)
Drop go1.12 support and linting. (#15)
fix: panic (#14)

check weather rows.Err is checked

09 Nov 07:13
Compare
Choose a tag to compare

check weather rows.Err is checked