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:
1 parent
043e307663
commit
465358609a
78 files changed
+2374
-1402
No files matched your search
@@ -65,7 +65,11 @@ func TestStorePersistsAndGeneratorProgresses(t *testing.T) {
|
||||
}
|
||||
|
||||
// The HTTP handler pages through the store without gaps or repeats.
|
||||
srv := &server{store: store2, baseURL: "", loc: time.UTC}
|
||||
srv := &server{
|
||||
store: store2,
|
||||
baseURL: "",
|
||||
loc: time.UTC,
|
||||
}
|
||||
seen := map[string]bool{}
|
||||
next := BasePath + "?updatedFrom=2026-10-07T00:00:00&limit=7"
|
||||
for pages := 0; next != ""; pages++ {
|
||||
@@ -105,7 +109,12 @@ func writeLines(t *testing.T, path string, lines ...string) {
|
||||
|
||||
func releaseLine(t *testing.T, ocid, id, tag string, at time.Time) string {
|
||||
t.Helper()
|
||||
b, err := json.Marshal(ocds.Release{OCID: ocid, ID: id, Date: at, Tag: []string{tag}})
|
||||
b, err := json.Marshal(ocds.Release{
|
||||
OCID: ocid,
|
||||
ID: id,
|
||||
Date: at,
|
||||
Tag: []string{tag},
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -117,7 +126,9 @@ func releaseLine(t *testing.T, ocid, id, tag string, at time.Time) string {
|
||||
func TestOpenStoreRecoversFromMessyFile(t *testing.T) {
|
||||
path := filepath.Join(t.TempDir(), "r.jsonl")
|
||||
t0 := time.Date(2026, 10, 8, 9, 0, 0, 0, time.UTC)
|
||||
writeLines(t, path,
|
||||
writeLines(
|
||||
t,
|
||||
path,
|
||||
releaseLine(t, "ocds-b", "000007-2026", "tender", t0.Add(2*time.Hour)),
|
||||
"{not json",
|
||||
"",
|
||||
@@ -225,9 +236,19 @@ func TestAppendKeepsDateOrder(t *testing.T) {
|
||||
}
|
||||
defer store.Close()
|
||||
t0 := time.Date(2026, 10, 8, 9, 0, 0, 0, time.UTC)
|
||||
store.Append(ocds.Release{OCID: "a", ID: "000001-2026", Date: t0, Tag: []string{"tender"}})
|
||||
store.Append(ocds.Release{
|
||||
OCID: "a",
|
||||
ID: "000001-2026",
|
||||
Date: t0,
|
||||
Tag: []string{"tender"},
|
||||
})
|
||||
store.Append(
|
||||
ocds.Release{OCID: "b", ID: "000002-2026", Date: t0.Add(-time.Hour), Tag: []string{"tender"}},
|
||||
ocds.Release{
|
||||
OCID: "b",
|
||||
ID: "000002-2026",
|
||||
Date: t0.Add(-time.Hour),
|
||||
Tag: []string{"tender"},
|
||||
},
|
||||
)
|
||||
if last, _ := store.Last(); !last.Equal(t0) {
|
||||
t.Errorf("Last = %s, want %s", last, t0)
|
||||
@@ -235,7 +256,11 @@ func TestAppendKeepsDateOrder(t *testing.T) {
|
||||
|
||||
// Appending to a closed store fails and leaves the store unchanged.
|
||||
store.Close()
|
||||
if err := store.Append(ocds.Release{OCID: "c", Date: t0, Tag: []string{"tender"}}); err == nil {
|
||||
if err := store.Append(ocds.Release{
|
||||
OCID: "c",
|
||||
Date: t0,
|
||||
Tag: []string{"tender"},
|
||||
}); err == nil {
|
||||
t.Error("append after close: expected error")
|
||||
}
|
||||
if store.Len() != 2 || store.HasOCID("c") {
|
||||
@@ -251,9 +276,19 @@ func TestRandomOpenDropsStaleProcedures(t *testing.T) {
|
||||
}
|
||||
defer store.Close()
|
||||
t0 := time.Date(2026, 10, 8, 9, 0, 0, 0, time.UTC)
|
||||
store.Append(ocds.Release{OCID: "old", ID: "000001-2026", Date: t0, Tag: []string{"tender"}})
|
||||
store.Append(ocds.Release{
|
||||
OCID: "old",
|
||||
ID: "000001-2026",
|
||||
Date: t0,
|
||||
Tag: []string{"tender"},
|
||||
})
|
||||
store.Append(
|
||||
ocds.Release{OCID: "new", ID: "000002-2026", Date: t0.Add(time.Hour), Tag: []string{"tender"}},
|
||||
ocds.Release{
|
||||
OCID: "new",
|
||||
ID: "000002-2026",
|
||||
Date: t0.Add(time.Hour),
|
||||
Tag: []string{"tender"},
|
||||
},
|
||||
)
|
||||
|
||||
//nolint:gosec // G404: seeded math/rand keeps the test deterministic
|
||||
|
||||
Reference in new issue
Block a user