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
@@ -25,8 +25,12 @@ func captureLogs(t *testing.T, level slog.Level) *bytes.Buffer {
|
||||
t.Helper()
|
||||
var buf bytes.Buffer
|
||||
def := slog.Default()
|
||||
slog.SetDefault(slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{Level: level})))
|
||||
t.Cleanup(func() { slog.SetDefault(def) })
|
||||
slog.SetDefault(slog.New(slog.NewTextHandler(&buf, &slog.HandlerOptions{
|
||||
Level: level,
|
||||
})))
|
||||
t.Cleanup(func() {
|
||||
slog.SetDefault(def)
|
||||
})
|
||||
return &buf
|
||||
}
|
||||
|
||||
@@ -62,7 +66,10 @@ func TestDefaults(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestLoggingSection(t *testing.T) {
|
||||
c := JSCLogging{Level: "info", File: "/tmp/x.log"}
|
||||
c := JSCLogging{
|
||||
Level: "info",
|
||||
File: "/tmp/x.log",
|
||||
}
|
||||
|
||||
if got, want := c.Keys(), []string{"level", "file"}; !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Keys = %v; want %v", got, want)
|
||||
@@ -142,7 +149,9 @@ func TestConfigLevelToLogLevel(t *testing.T) {
|
||||
if got := ConfigLevelToLogLevel(in); got != want {
|
||||
t.Errorf("ConfigLevelToLogLevel(%q) = %v; want %v", in, got, want)
|
||||
}
|
||||
c := JSCLogging{Level: in}
|
||||
c := JSCLogging{
|
||||
Level: in,
|
||||
}
|
||||
if got := c.LogLevel(); got != want {
|
||||
t.Errorf("LogLevel() with %q = %v; want %v", in, got, want)
|
||||
}
|
||||
@@ -150,7 +159,10 @@ func TestConfigLevelToLogLevel(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSourceSection(t *testing.T) {
|
||||
c := JSCSourcesSource{Enabled: true, Interval: time.Minute}
|
||||
c := JSCSourcesSource{
|
||||
Enabled: true,
|
||||
Interval: time.Minute,
|
||||
}
|
||||
|
||||
if got, want := c.Keys(), []string{"enabled", "interval"}; !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Keys = %v; want %v", got, want)
|
||||
@@ -458,7 +470,9 @@ func TestLoadFromViperInvalidValues(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestDatabaseSection(t *testing.T) {
|
||||
c := JSCDatabase{File: "./jobsearch.db"}
|
||||
c := JSCDatabase{
|
||||
File: "./jobsearch.db",
|
||||
}
|
||||
|
||||
if got, want := c.Keys(), []string{"file"}; !reflect.DeepEqual(got, want) {
|
||||
t.Errorf("Keys = %v; want %v", got, want)
|
||||
|
||||
Reference in new issue
Block a user