Skip to content

Commit 6ad195e

Browse files
committed
new checker 'formatter'
1 parent d6b0593 commit 6ad195e

30 files changed

+2703
-767
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99

1010
env:
1111
GO_VERSION: ^1.20
12-
GOLANGCI_LINT_VERSION: v1.56.2
12+
GOLANGCI_LINT_VERSION: v1.59.0
1313

1414
permissions:
1515
contents: read

.golangci.yml

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ issues:
77
# revive should check comments for exported (and not internal) code.
88
include: [ EXC0012, EXC0013, EXC0014 ]
99

10+
exclude-dirs:
11+
- internal/checkers/printf # A patched fork of go vet's printf.
12+
1013
exclude-rules:
1114
- path: "internal/testgen"
1215
linters: [ "revive" ]
@@ -22,6 +25,9 @@ issues:
2225
- path: "_test\\.go"
2326
linters: [ "lll" ]
2427

28+
- source: ' // want "'
29+
linters: [ "lll" ]
30+
2531
linters-settings:
2632
depguard:
2733
rules:

CONTRIBUTING.md

-39
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ Describe a new checker in [checkers section](./README.md#checkers).
136136
- [float-compare](#float-compare)
137137
- [http-const](#http-const)
138138
- [http-sugar](#http-sugar)
139-
- [no-fmt-mess](#no-fmt-mess)
140139
- [require-len](#require-len)
141140
- [suite-run](#suite-run)
142141
- [suite-test-name](#suite-test-name)
@@ -305,44 +304,6 @@ And similar idea for `assert.InEpsilonSlice` / `assert.InDeltaSlice`.
305304

306305
---
307306

308-
### no-fmt-mess
309-
310-
**Autofix**: true. <br>
311-
**Enabled by default**: maybe? <br>
312-
**Related issues**: [#33](https://github.com/Antonboom/testifylint/issues/33)
313-
314-
Those who are new to `testify` may be discouraged by the duplicative API:
315-
316-
```go
317-
func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool
318-
func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool
319-
```
320-
321-
The f-functions [were added a long time ago](https://github.com/stretchr/testify/pull/356) to eliminate
322-
`govet` [complain](https://go.googlesource.com/tools/+/refs/heads/release-branch.go1.12/go/analysis/passes/printf/printf.go?pli=1#506).
323-
324-
This introduces some inconsistency into the test code, and the next strategies are seen for the checker:
325-
326-
1) Forbid f-functions at all (also could be done through the [forbidigo](https://golangci-lint.run/usage/linters/#forbidigo) linter).
327-
328-
This will make it easier to migrate to [v2](https://github.com/stretchr/testify/issues/1089), because
329-
330-
> Format functions should not be accepted as they are equivalent to their "non-f" counterparts.
331-
332-
But it doesn't look like a "go way" and the `govet` won't be happy.
333-
334-
2) IMHO, a more appropriate option is to disallow the use of `msgAndArgs` in non-f assertions. Look at
335-
[the comment](https://github.com/stretchr/testify/issues/1089#issuecomment-1695059265).
336-
337-
But there will be no non-stylistic benefits from the checker in this case (depends on the view of API in `v2`).
338-
339-
Also, in the first iteration `no-fmt-mess` checker could help to avoid code like this:
340-
```go
341-
assert.Error(t, err, fmt.Sprintf("Profile %s should not be valid", test.profile))
342-
```
343-
344-
---
345-
346307
### require-len
347308

348309
The main idea: if code contains array/slice indexing,

0 commit comments

Comments
 (0)