Skip to content

Commit 05de8ee

Browse files
authored
Sync pkg/linters docs with registered analyzer set by adding timenowsub (#46723)
1 parent 20683af commit 05de8ee

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

‎pkg/linters/README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ This package currently provides custom Go analyzers in the following subpackages
5454
- `stringsindexcontains` — reports `strings.Index(s, substr)` comparisons with `-1` or `0` (e.g. `!= -1`, `>= 0`, `> -1`, `== -1`, `< 0`, `<= -1`) and their yoda-order variants that should use `strings.Contains(s, substr)` or `!strings.Contains(s, substr)` instead.
5555
- `timeafterleak` — reports `time.After` calls used as the channel-receive expression in a `select` case inside a `for` or `range` loop that leak a timer channel on each iteration when another case fires first.
5656
- `timesleepnocontext` — reports `time.Sleep` calls inside functions that already receive a `context.Context`, where a context-aware `select` should be used instead.
57+
- `timenowsub` — reports `time.Now().Sub(t)` calls that should be simplified to `time.Since(t)`.
5758
- `tolowerequalfold` — reports case-insensitive string comparisons using `strings.ToLower`/`ToUpper` that should use `strings.EqualFold`.
5859
- `trimleftright` — reports `strings.TrimLeft`/`TrimRight` calls with a multi-character literal cutset where `TrimPrefix`/`TrimSuffix` was likely intended.
5960
- `uncheckedtypeassertion` — reports single-value type assertions where unchecked panics are possible.
@@ -115,6 +116,7 @@ This package currently provides custom Go analyzers in the following subpackages
115116
| `stringsindexcontains` | Custom `go/analysis` analyzer that flags `strings.Index(s, substr)` comparisons with `-1` or `0` that should use `strings.Contains` or `!strings.Contains` |
116117
| `timeafterleak` | Custom `go/analysis` analyzer that flags `time.After` in `select` cases inside loops that leak a timer channel on each iteration when another case fires first |
117118
| `timesleepnocontext` | Custom `go/analysis` analyzer that flags `time.Sleep` calls in context-aware functions |
119+
| `timenowsub` | Custom `go/analysis` analyzer that flags `time.Now().Sub(t)` calls that should use `time.Since(t)` |
118120
| `tolowerequalfold` | Custom `go/analysis` analyzer that flags case-insensitive comparisons via `strings.ToLower`/`ToUpper` that should use `strings.EqualFold` |
119121
| `trimleftright` | Custom `go/analysis` analyzer that flags `strings.TrimLeft`/`TrimRight` calls with a multi-character literal cutset where `TrimPrefix`/`TrimSuffix` was likely intended |
120122
| `uncheckedtypeassertion` | Custom `go/analysis` analyzer that flags unchecked single-value type assertions |

‎pkg/linters/doc.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Package linters is a namespace for gh-aw's custom Go analysis linters.
22
//
3-
// All 53 active analyzers:
3+
// All 54 active analyzers:
44
//
55
// - appendbytestring — flags append(b, []byte(s)...) calls where s is a string that can be simplified to append(b, s...)
66
// - appendoneelement — flags append(s, []T{x}...) calls where a single-element slice literal is spread and can be simplified to append(s, x)
@@ -50,6 +50,7 @@
5050
// - stringsindexcontains — flags strings.Index(s, substr) comparisons that should use strings.Contains
5151
// - timeafterleak — flags time.After in select cases inside loops that leak timer channels
5252
// - timesleepnocontext — flags time.Sleep calls in context-aware functions that should propagate cancellation
53+
// - timenowsub — reports time.Now().Sub(t) calls that should be simplified to time.Since(t)
5354
// - tolowerequalfold — flags case-insensitive comparisons via ToLower/ToUpper that should use EqualFold
5455
// - trimleftright — flags strings.TrimLeft/TrimRight calls with a multi-character literal cutset where TrimPrefix/TrimSuffix was likely intended
5556
// - uncheckedtypeassertion — flags unchecked single-value type assertions

0 commit comments

Comments
 (0)