Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint warnings for generated internal types #3689

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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