|
1 |
| -# go-rowserr |
| 1 | +# go-uncalled |
2 | 2 |
|
3 |
| -[](https://pkg.go.dev/github.com/stevenh/go-rowserr) [](https://opensource.org/licenses/BSD-2-Clause) [](https://goreportcard.com/report/github.com/stevenh/go-rowserr) |
| 3 | +[](https://pkg.go.dev/github.com/stevenh/go-uncalled) [](https://opensource.org/licenses/BSD-2-Clause) [](https://goreportcard.com/report/github.com/stevenh/go-uncalled) |
4 | 4 |
|
5 |
| -go-rowserr is a static analysis tool for golang which checks for missing [Rows.Err()](https://pkg.go.dev/database/sql#Rows.Err) calls. |
| 5 | +go-uncalled is a static analysis tool for golang which checks for missing calls. |
6 | 6 |
|
7 | 7 | It is compatible with both standard and generic functions as introduced by [golang](https://go.dev/) version [1.18](https://go.dev/doc/go1.18).
|
8 | 8 |
|
9 | 9 | ## Install
|
10 | 10 |
|
11 |
| -You can install `rowserr` cmd using `go install` command. |
| 11 | +You can install the `uncalled` cmd using `go install` command. |
12 | 12 |
|
13 | 13 | ```bash
|
14 |
| -go install github.com/stevenh/go-rowserr/cmd/rowserr@latest |
| 14 | +go install github.com/stevenh/go-uncalled/cmd/uncalled@latest |
15 | 15 | ```
|
16 | 16 |
|
17 | 17 | ## How to use
|
18 | 18 |
|
19 |
| -You run `rowserr` with [go vet](https://pkg.go.dev/cmd/vet). |
| 19 | +You run `uncalled` with [go vet](https://pkg.go.dev/cmd/vet). |
20 | 20 |
|
21 | 21 | ```bash
|
22 |
| -go vet -vettool=$(which rowserr) ./... |
23 |
| -# github.com/stevenh/go-rowserr/test |
24 |
| -test/bad.go:10:2: rows.Err() must be checked |
| 22 | +go vet -vettool=$(which uncalled) ./... |
| 23 | +# github.com/stevenh/go-uncalled/test |
| 24 | +test/bad.go:10:2: rows.Err() must be called |
25 | 25 | ```
|
26 | 26 |
|
27 |
| -You can also run it directly: |
| 27 | +Or run it directly. |
28 | 28 | ```bash
|
29 |
| -rowserr ./... |
30 |
| -# github.com/stevenh/go-rowserr/test |
31 |
| -test/bad.go:10:2: rows.Err() must be checked |
| 29 | +uncalled ./... |
| 30 | +# github.com/stevenh/go-uncalled/test |
| 31 | +test/bad.go:10:2: rows.Err() must be called |
32 | 32 | ```
|
33 | 33 |
|
34 |
| -Additional package to check can be added using `-packages <pk1,pkg2...pkgN>`. |
| 34 | +A custom configuration can be loaded using `-config <filename>`. |
35 | 35 |
|
36 | 36 | The version can be checked with `-version`.
|
37 | 37 |
|
38 |
| -By default this checks the following packages: |
39 |
| - |
40 |
| -- [database/sql](https://pkg.go.dev/database/sql) |
41 |
| -- [github.com/jmoiron/sqlx](https://pkg.go.dev/github.com/jmoiron/sqlx) |
| 38 | +By default it includes the rules in: |
| 39 | +[pkg/uncalled/.uncalled.yaml](pkg/uncalled/.uncalled.yaml) |
42 | 40 |
|
43 | 41 | ## Analyzer
|
44 | 42 |
|
45 |
| -`rowserr` validates that code which uses [database/sql](https://pkg.go.dev/database/sql) and similar packages, to obtain [Rows](https://pkg.go.dev/database/sql#Rows) calls [Rows.Err()](https://pkg.go.dev/database/sql#Rows.Err) as described by |
| 43 | +`uncalled` validates that code to ensure expected calls are made. |
| 44 | + |
| 45 | +Its default config checks calls to [database/sql](https://pkg.go.dev/database/sql) and similar packages, that obtain [Rows](https://pkg.go.dev/database/sql#Rows) calls [Rows.Err()](https://pkg.go.dev/database/sql#Rows.Err) as described by |
46 | 46 |
|
47 | 47 | - [sql.Rows.Next](https://pkg.go.dev/database/sql#Rows.Next)
|
48 | 48 | - [sql.Rows.NextResultSet](https://pkg.go.dev/database/sql#Rows.NextResultSet)
|
@@ -76,7 +76,7 @@ if err = rows.Err(); err != nil {
|
76 | 76 | }
|
77 | 77 | ```
|
78 | 78 |
|
79 |
| -`rowserr` helps uncover such errors which will result in incomplete data if an error is triggered while processing rows. |
| 79 | +`uncalled` helps uncover such errors which will result in incomplete data if an error is triggered while processing rows. |
80 | 80 | This can happen when a connection becomes invalid, this causes [Rows.Next()](https://pkg.go.dev/database/sql#Rows.Next) or [sql.Rows.NextResultSet](https://pkg.go.dev/database/sql#Rows.NextResultSet) to return false without processing all rows.
|
81 | 81 |
|
82 | 82 | ## Inspired by
|
|
0 commit comments