Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5d65957

Browse filesBrowse files
committed
chore: fix code quality
1 parent a7142b6 commit 5d65957
Copy full SHA for 5d65957

File tree

Expand file treeCollapse file tree

13 files changed

+32
-30
lines changed
Filter options
Expand file treeCollapse file tree

13 files changed

+32
-30
lines changed

‎book/checkout.go

Copy file name to clipboardExpand all lines: book/checkout.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (b *Book) Checkout(step string) error {
3737
// FIXME: keep vendor/ node_modules/ around before git clean, but them back as they will be updated the right way, less Internet traffic
3838
// FIXME: if the checkout is to a later step, no need to remove the DB, we can just migrate it
3939
os.Chdir(b.Dir)
40-
step = strings.Replace(step, ".", "-", -1)
40+
step = strings.ReplaceAll(step, ".", "-")
4141
tag := fmt.Sprintf("step-%s", step)
4242
branch := "work-" + tag
4343
printBanner("<comment>[GIT]</> Check for not yet committed changes", b.Debug)

‎commands/local_new.go

Copy file name to clipboardExpand all lines: commands/local_new.go
+9-8Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,21 +307,22 @@ func parseDockerComposeServices(dir string) []*CloudService {
307307
for _, service := range project.Services {
308308
for _, port := range service.Ports {
309309
var s *CloudService
310-
if port.Target == 3306 {
310+
switch port.Target {
311+
case 3306:
311312
s = &CloudService{Type: "mysql"}
312-
} else if port.Target == 5432 {
313+
case 5432:
313314
s = &CloudService{Type: "postgresql"}
314-
} else if port.Target == 6379 {
315+
case 6379:
315316
s = &CloudService{Type: "redis"}
316-
} else if port.Target == 11211 {
317+
case 11211:
317318
s = &CloudService{Type: "memcached"}
318-
} else if port.Target == 5672 {
319+
case 5672:
319320
s = &CloudService{Type: "rabbitmq"}
320-
} else if port.Target == 9200 {
321+
case 9200:
321322
s = &CloudService{Type: "elasticsearch"}
322-
} else if port.Target == 27017 {
323+
case 27017:
323324
s = &CloudService{Type: "mongodb"}
324-
} else if port.Target == 9092 {
325+
case 9092:
325326
s = &CloudService{Type: "kafka"}
326327
}
327328
_, done := seen[service.Name]

‎commands/local_proxy_start.go

Copy file name to clipboardExpand all lines: commands/local_proxy_start.go
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ var localProxyStartCmd = &console.Command{
112112
if err != nil {
113113
return errors.WithStack(err)
114114
}
115-
var lw io.Writer
116-
lw = f
115+
var lw io.Writer = f
117116
logger := zerolog.New(decorateLogger(lw, c.Bool("no-humanize"))).With().Timestamp().Logger()
118117

119118
config, err := proxy.Load(homeDir)

‎envs/docker.go

Copy file name to clipboardExpand all lines: envs/docker.go
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -469,11 +469,12 @@ func (l *Local) dockerServiceToRelationship(client *docker.Client, container con
469469
"rel": "simple",
470470
}
471471
// Official HTTP(s) ports or well know alternatives
472-
if p.PrivatePort == 80 || p.PrivatePort == 8008 || p.PrivatePort == 8080 || p.PrivatePort == 8081 {
472+
switch p.PrivatePort {
473+
case 80, 8008, 8080, 8081:
473474
rels[""]["scheme"] = "http"
474-
} else if p.PrivatePort == 443 || p.PrivatePort == 8443 {
475+
case 443, 8443:
475476
rels[""]["scheme"] = "https"
476-
} else {
477+
default:
477478
rels[""]["scheme"] = "tcp"
478479
}
479480
return rels

‎envs/envs.go

Copy file name to clipboardExpand all lines: envs/envs.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func extractRelationshipsEnvs(env Environment) Envs {
121121
if i != 0 {
122122
prefix = fmt.Sprintf("%s_%d_", key, i)
123123
}
124-
prefix = strings.Replace(prefix, "-", "_", -1)
124+
prefix = strings.ReplaceAll(prefix, "-", "_")
125125

126126
// HA support via scheme-replica
127127
isPostgreSQL := strings.HasPrefix(scheme.(string), "pgsql")

‎envs/local.go

Copy file name to clipboardExpand all lines: envs/local.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (l *Local) FindRelationshipPrefix(frel, fscheme string) string {
6868
if i != 0 {
6969
prefix = fmt.Sprintf("%s_%d_", key, i)
7070
}
71-
return strings.Replace(prefix, "-", "_", -1)
71+
return strings.ReplaceAll(prefix, "-", "_")
7272
}
7373
}
7474
}
@@ -105,7 +105,7 @@ func (l *Local) FindServiceUrl(serviceOrRelationship string) (string, bool) {
105105
continue
106106
}
107107

108-
prefix := fmt.Sprintf("%s_", strings.Replace(strings.ToUpper(serviceOrRelationship), "-", "_", -1))
108+
prefix := fmt.Sprintf("%s_", strings.ReplaceAll(strings.ToUpper(serviceOrRelationship), "-", "_"))
109109
if i != 0 {
110110
prefix += fmt.Sprintf("%d_", i)
111111
}
@@ -128,7 +128,7 @@ func (l *Local) FindServiceUrl(serviceOrRelationship string) (string, bool) {
128128
continue
129129
}
130130

131-
prefix := fmt.Sprintf("%s_", strings.Replace(strings.ToUpper(key), "-", "_", -1))
131+
prefix := fmt.Sprintf("%s_", strings.ReplaceAll(strings.ToUpper(key), "-", "_"))
132132
if i != 0 {
133133
prefix += fmt.Sprintf("%d_", i)
134134
}

‎humanlog/symfony.go

Copy file name to clipboardExpand all lines: humanlog/symfony.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131

3232
// [2018-11-19 12:52:00] console.DEBUG: www {"xxx":"yyy","code":1} []
3333
// or [2019-11-13T07:16:50.260544+01:00] console.DEBUG: www {"xxx":"yyy","code":1} []
34-
var symfonyLogLineRegexp = regexp.MustCompile("^\\[(\\d{4}\\-\\d{2}\\-\\d{2} \\d{2}\\:\\d{2}\\:\\d{2}|\\d{4}\\-\\d{2}\\-\\d{2}T\\d{2}\\:\\d{2}\\:\\d{2}\\.\\d+\\+\\d{2}\\:\\d{2})\\] ([^\\.]+)\\.([^\\:]+)\\: (.+) (\\[.*?\\]|{.*?}) (\\[.*?\\]|{.*?})\\s*$")
34+
var symfonyLogLineRegexp = regexp.MustCompile(`^\[(\d{4}\-\d{2}\-\d{2} \d{2}\:\d{2}\:\d{2}|\d{4}\-\d{2}\-\d{2}T\d{2}\:\d{2}\:\d{2}\.\d+\+\d{2}\:\d{2})\] ([^\.]+)\.([^\:]+)\: (.+) (\[.*?\]|{.*?}) (\[.*?\]|{.*?})\s*$`)
3535

3636
func convertSymfonyLog(in []byte) (*line, error) {
3737
allMatches := symfonyLogLineRegexp.FindAllSubmatch(in, -1)

‎local/fcgi_client/fcgiclient.go

Copy file name to clipboardExpand all lines: local/fcgi_client/fcgiclient.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ type bufWriter struct {
251251
}
252252

253253
func (w *bufWriter) Close() error {
254-
if err := w.Writer.Flush(); err != nil {
254+
if err := w.Flush(); err != nil {
255255
w.closer.Close()
256256
return errors.WithStack(err)
257257
}

‎local/html/html.go

Copy file name to clipboardExpand all lines: local/html/html.go
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
)
2626

2727
func CreateAction(url, text string, args ...interface{}) string {
28-
text = strings.Replace(text, "\n", "<br>", -1)
28+
text = strings.ReplaceAll(text, "\n", "<br>")
2929
text = fmt.Sprintf(text, args...)
3030
return fmt.Sprintf(`<div style="text-align: center"><span class="button"><a href="%s">%s</a></span></div>`, url, text)
3131
}
@@ -43,7 +43,7 @@ func CreateTerminal(text string, args ...interface{}) string {
4343
}
4444

4545
func doCreateTerminal(text string, color string, args ...interface{}) string {
46-
text = strings.Replace(text, "\n", "<br>", -1)
46+
text = strings.ReplaceAll(text, "\n", "<br>")
4747
text = fmt.Sprintf(text, args...)
4848
return fmt.Sprintf(`
4949
<div style="background-color:%s;padding:20px" class="terminal">

‎local/php/envs.go

Copy file name to clipboardExpand all lines: local/php/envs.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func (p *Server) generateEnv(req *http.Request) map[string]string {
8080

8181
// iterate over request headers and append them to the environment variables in the valid format
8282
for k, v := range req.Header {
83-
key := strings.Replace(strings.ToUpper(k), "-", "_", -1)
83+
key := strings.ReplaceAll(strings.ToUpper(k), "-", "_")
8484
// ignore HTTP_HOST -- see https://httpoxy.org/
8585
if key == "HOST" {
8686
continue

‎local/pid/pidfile.go

Copy file name to clipboardExpand all lines: local/pid/pidfile.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func (p *PidFile) WaitForExit() error {
146146
select {
147147
case err := <-ch:
148148
return err
149-
case _ = <-time.After(30 * time.Second):
149+
case <-time.After(30 * time.Second):
150150
return errors.Errorf("Time out detected during \"%s\" process exit", p.ShortName())
151151
}
152152
}

‎local/proxy/config.go

Copy file name to clipboardExpand all lines: local/proxy/config.go
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ func (c *Config) doNormalizeDomain(domain string) string {
282282
continue
283283
}
284284
// glob matching
285-
if strings.HasSuffix(domain, strings.Replace(d, "*.", ".", -1)) {
285+
if strings.HasSuffix(domain, strings.ReplaceAll(d, "*.", ".")) {
286286
m := d + "." + c.TLD
287287
// always use the longest possible domain for matching
288288
if len(m) > len(match) {

‎local/proxy/proxy.go

Copy file name to clipboardExpand all lines: local/proxy/proxy.go
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,11 @@ func New(config *Config, ca *cert.CA, logger *log.Logger, debug bool) *Proxy {
188188
}
189189
r.URL.Scheme = "http"
190190
r.URL.Host = r.Host
191-
if r.URL.Path == "/proxy.pac" {
191+
switch r.URL.Path {
192+
case "/proxy.pac":
192193
p.servePacFile(w, r)
193194
return
194-
} else if r.URL.Path == "/" {
195+
case "/":
195196
p.serveIndex(w, r)
196197
return
197198
}
@@ -310,7 +311,7 @@ $ symfony server:start --daemon --dir=%s`,
310311
}
311312

312313
func (p *Proxy) Start() error {
313-
go p.Config.Watch()
314+
go p.Watch()
314315
return errors.WithStack(http.ListenAndServe(":"+strconv.Itoa(p.Port), p.proxy))
315316
}
316317

@@ -322,7 +323,7 @@ func (p *Proxy) servePacFile(w http.ResponseWriter, r *http.Request) {
322323
// No need to fall back to p.Host and p.Port as r.Host is already checked
323324
// upper in the stacktrace.
324325
w.Header().Add("Content-Type", "application/x-ns-proxy-autoconfig")
325-
w.Write([]byte(fmt.Sprintf(`// Only proxy *.%s requests
326+
fmt.Fprintf(w, `// Only proxy *.%s requests
326327
// Configuration file in ~/.symfony5/proxy.json
327328
function FindProxyForURL (url, host) {
328329
if (dnsDomainIs(host, '.%s')) {
@@ -335,7 +336,7 @@ function FindProxyForURL (url, host) {
335336
336337
return 'DIRECT';
337338
}
338-
`, p.TLD, p.TLD, r.Host)))
339+
`, p.TLD, p.TLD, r.Host)
339340
}
340341

341342
func (p *Proxy) serveIndex(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.