Skip to content

Commit

Permalink
Merge pull request #833 from alexandear/refactor/simplify-parse-confi…
Browse files Browse the repository at this point in the history
…g-templates

Simplify parseConfigTemplates implementation
  • Loading branch information
LandonTClipp authored Oct 23, 2024
2 parents f9da2b6 + e314ba8 commit f1e8da9
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions pkg/outputter.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,9 @@ func (*FileOutputStreamProvider) underscoreCaseName(caseName string) string {
func parseConfigTemplates(ctx context.Context, c *config.Config, iface *Interface) error {
log := zerolog.Ctx(ctx)

isExported := ast.IsExported(iface.Name)
var mock string
if isExported {
mock := "mock"
if ast.IsExported(iface.Name) {
mock = "Mock"
} else {
mock = "mock"
}

workingDir, err := os.Getwd()
Expand Down Expand Up @@ -248,12 +245,10 @@ func parseConfigTemplates(ctx context.Context, c *config.Config, iface *Interfac
"outpkg": &c.Outpkg,
}

numIterations := 0
changesMade := true
for changesMade {
if numIterations >= 20 {
msg := "infinite loop in template variables detected"
log.Error().Msg(msg)
for i := 0; changesMade; i++ {
if i >= 20 {
log.Error().Msg("infinite loop in template variables detected")
for key, val := range templateMap {
l := log.With().Str("variable-name", key).Str("variable-value", *val).Logger()
l.Error().Msg("config variable value")
Expand Down Expand Up @@ -282,7 +277,6 @@ func parseConfigTemplates(ctx context.Context, c *config.Config, iface *Interfac
changesMade = true
}
}
numIterations += 1
}

return nil
Expand Down

0 comments on commit f1e8da9

Please sign in to comment.