Skip to content

Commit

Permalink
Fix lint warnings for generated internal types (cadence-workflow#3689)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Dawson <[email protected]>
  • Loading branch information
2 people authored and yux0 committed May 4, 2021
1 parent c05a593 commit 04fb87a
Show file tree
Hide file tree
Showing 5 changed files with 997 additions and 996 deletions.
10 changes: 10 additions & 0 deletions common/types/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ const licence = `// Copyright (c) 2017-2020 Uber Technologies Inc.
`

func internalName(name string) string {
return noUnderscores(capitalizeID(name))
}

func noUnderscores(name string) string {
return strings.ReplaceAll(name, "_", "")
}

func capitalizeID(name string) string {
if index := strings.Index(name, "Id"); index > 0 {
nextWordIndex := index + len("Id")
if nextWordIndex >= len(name) || unicode.IsUpper([]rune(name)[nextWordIndex]) {
Expand Down Expand Up @@ -208,6 +216,7 @@ func To{{internal .Name}}(t {{if .IsPointer}}*{{end}}{{.ThriftPackage}}.{{.Name}
`))

var historyMapperAdditions = template.Must(template.New("history mapper additions").Parse(`
// FromProcessingQueueStateArrayMap converts internal ProcessingQueueState array map to thrift
func FromProcessingQueueStateArrayMap(t map[string][]*types.ProcessingQueueState) map[string][]*history.ProcessingQueueState {
if t == nil {
return nil
Expand All @@ -219,6 +228,7 @@ func FromProcessingQueueStateArrayMap(t map[string][]*types.ProcessingQueueState
return v
}
// ToProcessingQueueStateArrayMap converts thrift ProcessingQueueState array map to internal
func ToProcessingQueueStateArrayMap(t map[string][]*history.ProcessingQueueState) map[string][]*types.ProcessingQueueState {
if t == nil {
return nil
Expand Down
Loading

0 comments on commit 04fb87a

Please sign in to comment.