diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2025-01-17 10:28:37 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2025-01-17 10:02:07 +0000 |
| commit | bb91bdd45a9407e6594eb36266e74db1e50210a0 (patch) | |
| tree | f6b2a69ef250d37acdcf3006dfa349d9697a1d23 /tools/syz-linter/testdata | |
| parent | 5d04aae8969f6c72318ce0a4cde4f027766b1a55 (diff) | |
tools/syz-linter: suggest use of min/max functions
They are shorter, more readable, and don't require temp vars.
Diffstat (limited to 'tools/syz-linter/testdata')
| -rw-r--r-- | tools/syz-linter/testdata/src/lintertest/lintertest.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/syz-linter/testdata/src/lintertest/lintertest.go b/tools/syz-linter/testdata/src/lintertest/lintertest.go index 650893be3..d52b087ea 100644 --- a/tools/syz-linter/testdata/src/lintertest/lintertest.go +++ b/tools/syz-linter/testdata/src/lintertest/lintertest.go @@ -123,3 +123,16 @@ func varDecls() { var d int = 0 // want "Don't use both var, type and value in variable declarations" _, _, _, _ = a, b, c, d } + +func minmax() { + x, y := 0, 0 + if x < y + 1 { // want "Use max function instead" + x = y + 1 + } + if x >= y { // want "Use max function instead" + y = x + } + if x > 10 { // want "Use min function instead" + x = 10 + } +} |
