Naming, layout and comments: descriptive full-word names, one item per line in wrapped calls and literals, and doc comments on exported names

Short and single-letter names in application code become full words (tests
keep theirs). Wrapped calls, signatures and composite literals put one item
per line, and one-line function bodies are expanded. Exported names and
groups of constants get doc comments, and comments refer to the renamed
identifiers.
This commit is contained in:
bwilliams committed 2026-10-15 16:12:56 +01:00
1 parent 043e307663
commit 465358609a
78 files changed
+2374 -1402

No files matched your search

+9 -3
View File
@@ -12,7 +12,9 @@ import (
func TestRateLimitWindows(t *testing.T) {
now := time.Date(2026, 10, 6, 10, 3, 20, 0, time.UTC) // first request of the hour
rl := NewRateLimiter(12, 5*time.Minute)
rl.now = func() time.Time { return now }
rl.now = func() time.Time {
return now
}
for i := 0; i < 12; i++ {
if ok, _ := rl.allow("a"); !ok {
@@ -63,7 +65,9 @@ func TestClientKey(t *testing.T) {
func TestRateLimitMiddleware(t *testing.T) {
now := time.Date(2026, 10, 6, 10, 0, 0, 0, time.UTC)
rl := NewRateLimiter(2, 5*time.Minute)
rl.now = func() time.Time { return now }
rl.now = func() time.Time {
return now
}
calls := 0
h := rl.Middleware(func(w http.ResponseWriter, req *http.Request) {
@@ -108,7 +112,9 @@ func TestRateLimitMiddleware(t *testing.T) {
func TestRateLimitPrunesStaleClients(t *testing.T) {
now := time.Date(2026, 10, 6, 10, 30, 0, 0, time.UTC)
rl := NewRateLimiter(1, time.Minute)
rl.now = func() time.Time { return now }
rl.now = func() time.Time {
return now
}
for i := 0; i <= 10000; i++ {
rl.allow(strconv.Itoa(i))