concourse / concourse

Function call can be replaced with helper function CRT-A0010
Anti-pattern
Major
4 months ago4 years old
use strings.ReplaceAll method in strings.Replace(taskFileContents, "))", "END_VAR", -1)
 72			// contain unresolved variables in "task.yml":((task_content)), we will pre-process task
 73			// contents and temporarily replace "((" with "START_VAR" and "))" with "END_VAR"
 74			taskFileContents = strings.Replace(taskFileContents, "((", "START_VAR", -1)
 75			taskFileContents = strings.Replace(taskFileContents, "))", "END_VAR", -1) 76
 77			// then when we run the pipeline itself, it will contain an additional step called 'process-task-definition'
 78			// to do a backwards conversion to "((" and "))" using taskUnwrapContents
use strings.ReplaceAll method in strings.Replace(taskFileContents, "((", "START_VAR", -1)
 71			// since we are using create_files() in mock resource and we don't want pipeline resource to
 72			// contain unresolved variables in "task.yml":((task_content)), we will pre-process task
 73			// contents and temporarily replace "((" with "START_VAR" and "))" with "END_VAR"
 74			taskFileContents = strings.Replace(taskFileContents, "((", "START_VAR", -1) 75			taskFileContents = strings.Replace(taskFileContents, "))", "END_VAR", -1)
 76
 77			// then when we run the pipeline itself, it will contain an additional step called 'process-task-definition'
use strings.ReplaceAll method in strings.Replace(strings.ToLower(env), "_", "-", -1)
196}
197
198func flagify(env string) string {
199	return strings.Replace(strings.ToLower(env), "_", "-", -1)200}
201
202func getGdnFlagsFromConfig(configPath string) (GdnBinaryFlags, error) {
use strings.ReplaceAll method in strings.Replace(typedNode, fmt.Sprintf("((%s))", name), foundValStr, -1)
113				switch foundVal.(type) {
114				case string, int, int16, int32, int64, uint, uint16, uint32, uint64, json.Number:
115					foundValStr := fmt.Sprintf("%v", foundVal)
116					typedNode = strings.Replace(typedNode, fmt.Sprintf("((%s))", name), foundValStr, -1)117				default:
118					return nil, InvalidInterpolationError{
119						Name:  name,
use strings.ReplaceAll method in strings.Replace(strings.Join(lines, ","), " ", "", -1)
101func presentMap(version interface{}) string {
102	marshalled, _ := yaml.Marshal(version)
103	lines := strings.Split(strings.TrimSpace(string(marshalled)), "\n")
104	return strings.Replace(strings.Join(lines, ","), " ", "", -1)105}
106
107func presentResourceType(resourceType *atc.VolumeResourceType) string {