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

chore: fix some code quality #612

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

Merged
merged 1 commit into from
May 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion 2 book/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (b *Book) Checkout(step string) error {
// FIXME: keep vendor/ node_modules/ around before git clean, but them back as they will be updated the right way, less Internet traffic
// FIXME: if the checkout is to a later step, no need to remove the DB, we can just migrate it
os.Chdir(b.Dir)
step = strings.Replace(step, ".", "-", -1)
step = strings.ReplaceAll(step, ".", "-")
tag := fmt.Sprintf("step-%s", step)
branch := "work-" + tag
printBanner("<comment>[GIT]</> Check for not yet committed changes", b.Debug)
Expand Down
17 changes: 9 additions & 8 deletions 17 commands/local_new.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,21 +307,22 @@ func parseDockerComposeServices(dir string) []*CloudService {
for _, service := range project.Services {
for _, port := range service.Ports {
var s *CloudService
if port.Target == 3306 {
switch port.Target {
case 3306:
s = &CloudService{Type: "mysql"}
} else if port.Target == 5432 {
case 5432:
s = &CloudService{Type: "postgresql"}
} else if port.Target == 6379 {
case 6379:
s = &CloudService{Type: "redis"}
} else if port.Target == 11211 {
case 11211:
s = &CloudService{Type: "memcached"}
} else if port.Target == 5672 {
case 5672:
s = &CloudService{Type: "rabbitmq"}
} else if port.Target == 9200 {
case 9200:
s = &CloudService{Type: "elasticsearch"}
} else if port.Target == 27017 {
case 27017:
s = &CloudService{Type: "mongodb"}
} else if port.Target == 9092 {
case 9092:
s = &CloudService{Type: "kafka"}
}
_, done := seen[service.Name]
Expand Down
3 changes: 1 addition & 2 deletions 3 commands/local_proxy_start.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ var localProxyStartCmd = &console.Command{
if err != nil {
return errors.WithStack(err)
}
var lw io.Writer
lw = f
var lw io.Writer = f
logger := zerolog.New(decorateLogger(lw, c.Bool("no-humanize"))).With().Timestamp().Logger()

config, err := proxy.Load(homeDir)
Expand Down
7 changes: 4 additions & 3 deletions 7 envs/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,11 +469,12 @@ func (l *Local) dockerServiceToRelationship(client *docker.Client, container con
"rel": "simple",
}
// Official HTTP(s) ports or well know alternatives
if p.PrivatePort == 80 || p.PrivatePort == 8008 || p.PrivatePort == 8080 || p.PrivatePort == 8081 {
switch p.PrivatePort {
case 80, 8008, 8080, 8081:
rels[""]["scheme"] = "http"
} else if p.PrivatePort == 443 || p.PrivatePort == 8443 {
case 443, 8443:
rels[""]["scheme"] = "https"
} else {
default:
rels[""]["scheme"] = "tcp"
}
return rels
Expand Down
2 changes: 1 addition & 1 deletion 2 envs/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func extractRelationshipsEnvs(env Environment) Envs {
if i != 0 {
prefix = fmt.Sprintf("%s_%d_", key, i)
}
prefix = strings.Replace(prefix, "-", "_", -1)
prefix = strings.ReplaceAll(prefix, "-", "_")

// HA support via scheme-replica
isPostgreSQL := strings.HasPrefix(scheme.(string), "pgsql")
Expand Down
6 changes: 3 additions & 3 deletions 6 envs/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (l *Local) FindRelationshipPrefix(frel, fscheme string) string {
if i != 0 {
prefix = fmt.Sprintf("%s_%d_", key, i)
}
return strings.Replace(prefix, "-", "_", -1)
return strings.ReplaceAll(prefix, "-", "_")
}
}
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (l *Local) FindServiceUrl(serviceOrRelationship string) (string, bool) {
continue
}

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

prefix := fmt.Sprintf("%s_", strings.Replace(strings.ToUpper(key), "-", "_", -1))
prefix := fmt.Sprintf("%s_", strings.ReplaceAll(strings.ToUpper(key), "-", "_"))
if i != 0 {
prefix += fmt.Sprintf("%d_", i)
}
Expand Down
2 changes: 1 addition & 1 deletion 2 humanlog/symfony.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (

// [2018-11-19 12:52:00] console.DEBUG: www {"xxx":"yyy","code":1} []
// or [2019-11-13T07:16:50.260544+01:00] console.DEBUG: www {"xxx":"yyy","code":1} []
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*$")
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*$`)

func convertSymfonyLog(in []byte) (*line, error) {
allMatches := symfonyLogLineRegexp.FindAllSubmatch(in, -1)
Expand Down
2 changes: 1 addition & 1 deletion 2 local/fcgi_client/fcgiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ type bufWriter struct {
}

func (w *bufWriter) Close() error {
if err := w.Writer.Flush(); err != nil {
if err := w.Flush(); err != nil {
w.closer.Close()
return errors.WithStack(err)
}
Expand Down
4 changes: 2 additions & 2 deletions 4 local/html/html.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
)

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

func doCreateTerminal(text string, color string, args ...interface{}) string {
text = strings.Replace(text, "\n", "<br>", -1)
text = strings.ReplaceAll(text, "\n", "<br>")
text = fmt.Sprintf(text, args...)
return fmt.Sprintf(`
<div style="background-color:%s;padding:20px" class="terminal">
Expand Down
2 changes: 1 addition & 1 deletion 2 local/php/envs.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (p *Server) generateEnv(req *http.Request) map[string]string {

// iterate over request headers and append them to the environment variables in the valid format
for k, v := range req.Header {
key := strings.Replace(strings.ToUpper(k), "-", "_", -1)
key := strings.ReplaceAll(strings.ToUpper(k), "-", "_")
// ignore HTTP_HOST -- see https://httpoxy.org/
if key == "HOST" {
continue
Expand Down
2 changes: 1 addition & 1 deletion 2 local/pid/pidfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (p *PidFile) WaitForExit() error {
select {
case err := <-ch:
return err
case _ = <-time.After(30 * time.Second):
case <-time.After(30 * time.Second):
return errors.Errorf("Time out detected during \"%s\" process exit", p.ShortName())
}
}
Expand Down
2 changes: 1 addition & 1 deletion 2 local/proxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ func (c *Config) doNormalizeDomain(domain string) string {
continue
}
// glob matching
if strings.HasSuffix(domain, strings.Replace(d, "*.", ".", -1)) {
if strings.HasSuffix(domain, strings.ReplaceAll(d, "*.", ".")) {
m := d + "." + c.TLD
// always use the longest possible domain for matching
if len(m) > len(match) {
Expand Down
11 changes: 6 additions & 5 deletions 11 local/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ func New(config *Config, ca *cert.CA, logger *log.Logger, debug bool) *Proxy {
}
r.URL.Scheme = "http"
r.URL.Host = r.Host
if r.URL.Path == "/proxy.pac" {
switch r.URL.Path {
case "/proxy.pac":
p.servePacFile(w, r)
return
} else if r.URL.Path == "/" {
case "/":
p.serveIndex(w, r)
return
}
Expand Down Expand Up @@ -310,7 +311,7 @@ $ symfony server:start --daemon --dir=%s`,
}

func (p *Proxy) Start() error {
go p.Config.Watch()
go p.Watch()
return errors.WithStack(http.ListenAndServe(":"+strconv.Itoa(p.Port), p.proxy))
}

Expand All @@ -322,7 +323,7 @@ func (p *Proxy) servePacFile(w http.ResponseWriter, r *http.Request) {
// No need to fall back to p.Host and p.Port as r.Host is already checked
// upper in the stacktrace.
w.Header().Add("Content-Type", "application/x-ns-proxy-autoconfig")
w.Write([]byte(fmt.Sprintf(`// Only proxy *.%s requests
fmt.Fprintf(w, `// Only proxy *.%s requests
// Configuration file in ~/.symfony5/proxy.json
function FindProxyForURL (url, host) {
if (dnsDomainIs(host, '.%s')) {
Expand All @@ -335,7 +336,7 @@ function FindProxyForURL (url, host) {

return 'DIRECT';
}
`, p.TLD, p.TLD, r.Host)))
`, p.TLD, p.TLD, r.Host)
}

func (p *Proxy) serveIndex(w http.ResponseWriter, r *http.Request) {
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.