Skip to content

Commit be23937

Browse files
committed
Ruleguard is acting strange... will move to another PR
1 parent cffcd71 commit be23937

File tree

1 file changed

+0
-49
lines changed

1 file changed

+0
-49
lines changed

scripts/rules.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -69,52 +69,3 @@ func doNotCallTFailNowInsideGoroutine(m dsl.Matcher) {
6969
Where(m["t"].Type.Implements("testing.TB") && m["fail"].Text.Matches("^(FailNow|Fatal|Fatalf)$")).
7070
Report("Do not call functions that may call t.FailNow in a goroutine, as this can cause data races (see testing.go:834)")
7171
}
72-
73-
// InTx checks to ensure the database used inside the transaction closure is the transaction
74-
// database, and not the original database that creates the tx.
75-
func InTx(m dsl.Matcher) {
76-
m.Import("github.com/coder/coder/coderd/database")
77-
78-
// ':=' and '=' are different matches. Really...
79-
m.Match(`
80-
$x.InTx(func($y database.Store) error {
81-
$*_
82-
$*_ := $x.$f($*_)
83-
$*_
84-
})
85-
`, `
86-
$x.InTx(func($y database.Store) error {
87-
$*_
88-
$*_ = $x.$f($*_)
89-
$*_
90-
})
91-
`).Where(m["x"].Text != m["y"].Text && m["x"].Type.Implements("database.Store")).
92-
At(m["f"]).
93-
Report("Do not use the database directly within the InTx closure. Use '$y' instead of '$x'.")
94-
95-
// When using a tx closure, ensure that if you pass the db to another
96-
// function inside the closure, it is the tx.
97-
// This will miss more complex cases such as passing the db as apart
98-
// of another struct.
99-
m.Match(
100-
`
101-
$x.InTx(func($y database.Store) error {
102-
$*_
103-
$*_ := $f($*_, $x, $*_)
104-
$*_
105-
})
106-
`, `
107-
$x.InTx(func($y database.Store) error {
108-
$*_
109-
$*_ = $f($*_, $x, $*_)
110-
$*_
111-
})
112-
`, `
113-
$x.InTx(func($y database.Store) error {
114-
$*_
115-
$f($*_, $x, $*_)
116-
$*_
117-
})
118-
`).Where(m["x"].Text != m["y"].Text && m["x"].Type.Implements("database.Store")).
119-
At(m["f"]).Report("Pass the tx database into the '$f' function inside the closure. Use '$y' over $x'")
120-
}

0 commit comments

Comments
 (0)