From 214ceb95a1cfce07f79a7e8ad2cbe92d9b8a4c05 Mon Sep 17 00:00:00 2001 From: Stefan Logue Date: Wed, 28 Aug 2024 15:53:15 +0100 Subject: [PATCH] refactor(config): use named fields in struct --- config.go | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/config.go b/config.go index c0de246..640daca 100644 --- a/config.go +++ b/config.go @@ -31,13 +31,11 @@ func loadConfig(fs afero.Fs) (LoadConfigReturn, error) { if err != nil { log.Debug("Error finding config file", "error", err) return LoadConfigReturn{ - defaultMessageTemplate, - defaultMessageWithTicketTemplate, - config.DefaultPrefixes, - nil, - nil, - defaultCommitTitleCharLimit, - true, + MessageTemplate: defaultMessageTemplate, + MessageWithTicketTemplate: defaultMessageWithTicketTemplate, + Prefixes: config.DefaultPrefixes, + CommitTitleCharLimit: defaultCommitTitleCharLimit, + ShowIntro: true, }, nil } @@ -48,13 +46,10 @@ func loadConfig(fs afero.Fs) (LoadConfigReturn, error) { err = c.LoadFile(filePath) if err != nil { return LoadConfigReturn{ - defaultMessageTemplate, - defaultMessageWithTicketTemplate, - nil, - nil, - nil, - defaultCommitTitleCharLimit, - true, + MessageTemplate: defaultMessageTemplate, + MessageWithTicketTemplate: defaultMessageWithTicketTemplate, + CommitTitleCharLimit: defaultCommitTitleCharLimit, + ShowIntro: true, }, fmt.Errorf("error parsing config file: %w", err) } @@ -89,12 +84,12 @@ func loadConfig(fs afero.Fs) (LoadConfigReturn, error) { c.MessageWithTicketTemplate = &messageWithTicketTemplate return LoadConfigReturn{ - messageTemplate, - messageWithTicketTemplate, - c.Prefixes.Options(), - c.Coauthors.Options(), - c.Boards.Options(), - *c.CommitTitleCharLimit, - *c.ShowIntro, + MessageTemplate: messageTemplate, + MessageWithTicketTemplate: messageWithTicketTemplate, + Prefixes: c.Prefixes.Options(), + Coauthors: c.Coauthors.Options(), + Boards: c.Boards.Options(), + CommitTitleCharLimit: *c.CommitTitleCharLimit, + ShowIntro: *c.ShowIntro, }, nil }