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
@@ -77,7 +77,9 @@ func TestFetchFunctions(t *testing.T) {
|
||||
"releases found",
|
||||
http.StatusOK,
|
||||
onePackage,
|
||||
func(err error) bool { return err == nil },
|
||||
func(err error) bool {
|
||||
return err == nil
|
||||
},
|
||||
"nil",
|
||||
},
|
||||
{"no releases", http.StatusOK, emptyPackage, func(err error) bool {
|
||||
@@ -92,7 +94,10 @@ func TestFetchFunctions(t *testing.T) {
|
||||
t.Run(fname+"/"+tc.name, func(t *testing.T) {
|
||||
srv, hits := ftsServer(t, tc.status, tc.body)
|
||||
err := fetch(
|
||||
context.Background(), slog.Default(), confFor(srv.URL), time.Now().Add(-time.Hour),
|
||||
context.Background(),
|
||||
slog.Default(),
|
||||
confFor(srv.URL),
|
||||
time.Now().Add(-time.Hour),
|
||||
)
|
||||
if !tc.check(err) {
|
||||
t.Fatalf("err = %v, want %s", err, tc.wantErr)
|
||||
@@ -204,7 +209,9 @@ func TestRunLogsSourceErrors(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
def := slog.Default()
|
||||
slog.SetDefault(slog.New(slog.NewTextHandler(&buf, nil)))
|
||||
t.Cleanup(func() { slog.SetDefault(def) })
|
||||
t.Cleanup(func() {
|
||||
slog.SetDefault(def)
|
||||
})
|
||||
|
||||
// A zero interval makes each worker fail straight away.
|
||||
conf := &config.JobSearchConfig{}
|
||||
@@ -253,7 +260,9 @@ func TestRunShutsDownOnWorkerError(t *testing.T) {
|
||||
conf.Sources.Sleeper.Enabled = true
|
||||
|
||||
done := make(chan error, 1)
|
||||
go func() { done <- Run(context.Background(), conf, time.Now().Add(-time.Hour)) }()
|
||||
go func() {
|
||||
done <- Run(context.Background(), conf, time.Now().Add(-time.Hour))
|
||||
}()
|
||||
|
||||
select {
|
||||
case err := <-done:
|
||||
|
||||
Reference in new issue
Block a user