diff --git a/.semgrep/config/go.yaml b/.semgrep/config/go.yaml new file mode 100644 index 0000000000..f73e5e43d7 --- /dev/null +++ b/.semgrep/config/go.yaml @@ -0,0 +1,18 @@ +rules: + - id: forgejo-switch-empty-case + pattern-either: + - pattern: |- + switch $_ { + case $_: + } + - patterns: + - pattern: |- + switch { + case $_: + } + languages: + - go + severity: ERROR + message: > + switch has a case block with no content. This is treated as "break" by Go, but developers may confuse it for + "fallthrough". To fix this error, disambiguate by using "break" or "fallthrough". diff --git a/.semgrep/tests/go.go b/.semgrep/tests/go.go new file mode 100644 index 0000000000..14c9a31912 --- /dev/null +++ b/.semgrep/tests/go.go @@ -0,0 +1,44 @@ +// Copyright 2014 The Gogs Authors. All rights reserved. +// SPDX-License-Identifier: MIT + +package cmd + +import ( + "context" + "os" + "os/signal" + "strings" + "syscall" + + _ "net/http/pprof" // Used for debugging if enabled and a web server is running + + "forgejo.org/modules/setting" +) + +func setPortEmptyCaseBad(port string) error { + setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, port, 1) + setting.HTTPPort = port + + // ruleid:forgejo-switch-empty-case + switch setting.Protocol { + case setting.HTTPUnix: + case setting.FCGI: + case setting.FCGIUnix: + default: + defaultLocalURL := string(setting.Protocol) + "://" + } + + // ok:forgejo-switch-empty-case + switch setting.Protocol { + case setting.HTTPUnix: + break + case setting.FCGI: + break + case setting.FCGIUnix: + break + default: + defaultLocalURL := string(setting.Protocol) + "://" + } + + return nil +} diff --git a/cmd/forgejo/forgejo.go b/cmd/forgejo/forgejo.go index 171ef1a71d..7b59eaab15 100644 --- a/cmd/forgejo/forgejo.go +++ b/cmd/forgejo/forgejo.go @@ -126,7 +126,9 @@ func installSignals(ctx context.Context) (context.Context, context.CancelFunc) { ) select { case <-signalChannel: + break case <-ctx.Done(): + break } cancel() signal.Reset() diff --git a/cmd/web.go b/cmd/web.go index 12a8cac797..683b19c82a 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -278,8 +278,11 @@ func setPort(port string) error { switch setting.Protocol { case setting.HTTPUnix: + break case setting.FCGI: + break case setting.FCGIUnix: + break default: defaultLocalURL := string(setting.Protocol) + "://" if setting.HTTPAddr == "0.0.0.0" { diff --git a/models/gitea_migrations/v1_13/v151.go b/models/gitea_migrations/v1_13/v151.go index a464e6e7a7..09abfd4b9e 100644 --- a/models/gitea_migrations/v1_13/v151.go +++ b/models/gitea_migrations/v1_13/v151.go @@ -25,6 +25,7 @@ func SetDefaultPasswordToArgon2(x *xorm.Engine) error { return err case setting.Database.Type.IsSQLite3(): // drop through + break default: log.Fatal("Unrecognized DB") } diff --git a/models/packages/descriptor.go b/models/packages/descriptor.go index 19e0e8f5d5..947144ec54 100644 --- a/models/packages/descriptor.go +++ b/models/packages/descriptor.go @@ -174,8 +174,10 @@ func GetPackageDescriptor(ctx context.Context, pv *PackageVersion) (*PackageDesc metadata = &debian.Metadata{} case TypeGeneric: // generic packages have no metadata + break case TypeGo: // go packages have no metadata + break case TypeHelm: metadata = &helm.Metadata{} case TypeNuGet: diff --git a/modules/eventsource/manager.go b/modules/eventsource/manager.go index 730cacd940..e0d7ab78c4 100644 --- a/modules/eventsource/manager.go +++ b/modules/eventsource/manager.go @@ -39,7 +39,9 @@ func (m *Manager) Register(uid int64) <-chan *Event { } select { case m.connection <- struct{}{}: + break default: + break } m.mutex.Unlock() return messenger.Register() diff --git a/modules/eventsource/manager_run.go b/modules/eventsource/manager_run.go index 0eaee5dc3c..48500feafc 100644 --- a/modules/eventsource/manager_run.go +++ b/modules/eventsource/manager_run.go @@ -47,7 +47,9 @@ loop: // empty the connection channel select { case <-m.connection: + break default: + break } } m.mutex.Unlock() @@ -63,7 +65,9 @@ loop: // We won't change the "then" time because there could be concurrency issues select { case <-timer.C: + break default: + break } continue } diff --git a/modules/eventsource/messenger.go b/modules/eventsource/messenger.go index 378e717126..380cb13f20 100644 --- a/modules/eventsource/messenger.go +++ b/modules/eventsource/messenger.go @@ -62,7 +62,9 @@ func (m *Messenger) SendMessage(message *Event) { channel := m.channels[i] select { case channel <- message: + break default: + break } } } diff --git a/modules/git/diff.go b/modules/git/diff.go index f745531edd..507dc5b2f5 100644 --- a/modules/git/diff.go +++ b/modules/git/diff.go @@ -221,6 +221,7 @@ func CutDiffAroundLine(originalDiff io.Reader, line int64, old bool, numbersOfLi } case '\\': // FIXME: handle `\ No newline at end of file` + break default: currentLine++ otherLine++ diff --git a/modules/git/pushoptions/pushoptions.go b/modules/git/pushoptions/pushoptions.go index e96ba0a339..3fa2e01c44 100644 --- a/modules/git/pushoptions/pushoptions.go +++ b/modules/git/pushoptions/pushoptions.go @@ -65,12 +65,8 @@ func (o *gitPushOptions) Parse(data string) bool { value = "true" } switch Key(key) { - case RepoPrivate: - case RepoTemplate: - case AgitTopic: - case AgitForcePush: - case AgitTitle: - case AgitDescription: + case RepoPrivate, RepoTemplate, AgitTopic, AgitForcePush, AgitTitle, AgitDescription: + break default: return false } diff --git a/modules/git/repo_stats.go b/modules/git/repo_stats.go index ef0865e3d3..881acdafcf 100644 --- a/modules/git/repo_stats.go +++ b/modules/git/repo_stats.go @@ -98,6 +98,7 @@ func (repo *Repository) GetCodeActivityStats(fromTime time.Time, branch string) } switch p { case 1: // Separator + break case 2: // Commit sha-1 stats.CommitCount++ case 3: // Author diff --git a/modules/graceful/manager.go b/modules/graceful/manager.go index db5738c94c..3b0115c51c 100644 --- a/modules/graceful/manager.go +++ b/modules/graceful/manager.go @@ -164,6 +164,7 @@ func (g *Manager) doHammerTime(d time.Duration) { g.lock.Lock() select { case <-g.hammerCtx.Done(): + break default: log.Warn("Setting Hammer condition") g.hammerCtxCancel() @@ -180,6 +181,7 @@ func (g *Manager) doTerminate() { g.lock.Lock() select { case <-g.terminateCtx.Done(): + break default: log.Warn("Terminating") g.terminateCtxCancel() diff --git a/modules/graceful/manager_common.go b/modules/graceful/manager_common.go index 892957e93f..87f18e382f 100644 --- a/modules/graceful/manager_common.go +++ b/modules/graceful/manager_common.go @@ -86,6 +86,7 @@ func (g *Manager) DoGracefulShutdown() { g.lock.Lock() select { case <-g.shutdownRequested: + break default: close(g.shutdownRequested) } diff --git a/modules/indexer/code/indexer.go b/modules/indexer/code/indexer.go index a3e20e1d5a..a414c40d0e 100644 --- a/modules/indexer/code/indexer.go +++ b/modules/indexer/code/indexer.go @@ -215,7 +215,9 @@ func Init() { } select { case waitChannel <- time.Since(start): + break case <-graceful.GetManager().IsShutdown(): + break } close(waitChannel) diff --git a/modules/indexer/issues/indexer.go b/modules/indexer/issues/indexer.go index dd7102713c..81ffcaaf5d 100644 --- a/modules/indexer/issues/indexer.go +++ b/modules/indexer/issues/indexer.go @@ -141,7 +141,9 @@ func InitIssueIndexer(syncReindex bool) { if syncReindex { select { case <-indexerInitWaitChannel: + break case <-graceful.GetManager().IsShutdown(): + break } } else if setting.Indexer.StartupTimeout > 0 { go func() { diff --git a/modules/log/event_writer_base.go b/modules/log/event_writer_base.go index 4de2b953c7..561166b2ad 100644 --- a/modules/log/event_writer_base.go +++ b/modules/log/event_writer_base.go @@ -80,7 +80,9 @@ func (b *EventWriterBaseImpl) Run(ctx context.Context) { if pause := b.GetPauseChan(); pause != nil { select { case <-pause: + break case <-ctx.Done(): + break } } } @@ -178,6 +180,7 @@ func eventWriterStopWait(w EventWriter) { close(w.Base().Queue) select { case <-w.Base().stopped: + break case <-time.After(2 * time.Second): FallbackErrorf("unable to stop log writer %q in time, skip", w.GetWriterName()) } diff --git a/modules/log/logger_impl.go b/modules/log/logger_impl.go index 76d7e6a821..9f25f9f7fb 100644 --- a/modules/log/logger_impl.go +++ b/modules/log/logger_impl.go @@ -58,6 +58,7 @@ func (l *LoggerImpl) SendLogEvent(event *Event) { } select { case w.Base().Queue <- formatted: + break default: bs, _ := json.Marshal(event) FallbackErrorf("log writer %q queue is full, event: %v", w.GetWriterName(), string(bs)) diff --git a/modules/markup/html.go b/modules/markup/html.go index 7f16502d5e..d60021bfbb 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -742,6 +742,7 @@ func shortLinkProcessor(ctx *RenderContext, node *html.Node) { // fast path: empty string, ignore case "": // leave image as false + break case ".jpg", ".jpeg", ".png", ".tif", ".tiff", ".webp", ".gif", ".bmp", ".ico", ".svg": image = true } diff --git a/modules/migration/retry_downloader.go b/modules/migration/retry_downloader.go index 1cacf5f375..ef3d78a5d9 100644 --- a/modules/migration/retry_downloader.go +++ b/modules/migration/retry_downloader.go @@ -44,6 +44,7 @@ func (d *RetryDownloader) retry(work func() error) error { case <-d.ctx.Done(): return d.ctx.Err() case <-time.After(time.Second * time.Duration(d.RetryDelay)): + break } } return err diff --git a/modules/proxyprotocol/conn.go b/modules/proxyprotocol/conn.go index 9434fa88a1..8414b8af35 100644 --- a/modules/proxyprotocol/conn.go +++ b/modules/proxyprotocol/conn.go @@ -259,9 +259,10 @@ func (p *Conn) readV2ProxyHeader() error { p.localAddr = p.conn.RemoteAddr() return nil case 0x1: - // - \x1 : PROXY : the connection was established on behalf of another node, - // and reflects the original connection endpoints. The receiver must then use - // the information provided in the protocol block to get original the address. + // - \x1 : PROXY : the connection was established on behalf of another node, + // and reflects the original connection endpoints. The receiver must then use + // the information provided in the protocol block to get original the address. + break default: // - other values are unassigned and must not be emitted by senders. Receivers // must drop connections presenting unexpected values here. @@ -466,7 +467,9 @@ func (p *Conn) readV1ProxyHeader() error { p.localAddr = p.conn.RemoteAddr() return nil case "TCP4": + break case "TCP6": + break default: p.conn.Close() return &ErrBadAddressType{parts[1]} diff --git a/modules/queue/workergroup.go b/modules/queue/workergroup.go index 3fb821ce69..2d1228db2c 100644 --- a/modules/queue/workergroup.go +++ b/modules/queue/workergroup.go @@ -56,6 +56,7 @@ func (q *WorkerPoolQueue[T]) doDispatchBatchToWorker(wg *workerGroup[T], flushCh full := false select { case q.batchChan <- batch: + break default: full = true } @@ -76,6 +77,7 @@ func (q *WorkerPoolQueue[T]) doDispatchBatchToWorker(wg *workerGroup[T], flushCh if full { select { case q.batchChan <- batch: + break case flush := <-flushChan: q.doWorkerHandle(batch) q.doFlush(wg, flush) @@ -105,7 +107,9 @@ func (q *WorkerPoolQueue[T]) doWorkerHandle(batch []T) { log.Error("Queue %q failed to handle batch of %d items, backoff for a few seconds", q.GetName(), len(batch)) select { case <-q.ctxRun.Done(): + break case <-time.After(time.Duration(unhandledItemRequeueDuration.Load())): + break } } for _, item := range unhandled { @@ -170,7 +174,9 @@ func (q *WorkerPoolQueue[T]) doStartNewWorker(wp *workerGroup[T]) { t.Reset(workerIdleDuration) select { case <-t.C: + break default: + break } case <-t.C: q.workerNumMu.Lock() @@ -296,6 +302,7 @@ func (q *WorkerPoolQueue[T]) doRun() { go func() { wg.wg.Wait(); close(workerDone) }() select { case <-workerDone: + break case <-time.After(shutdownTimeout): log.Error("Queue %q is shutting down, but workers are still running after timeout", q.GetName()) } diff --git a/modules/queue/workerqueue.go b/modules/queue/workerqueue.go index 6a71fc4fb4..c340bafa50 100644 --- a/modules/queue/workerqueue.go +++ b/modules/queue/workerqueue.go @@ -110,6 +110,7 @@ func (q *WorkerPoolQueue[T]) FlushWithContext(ctx context.Context, timeout time. // if it blocks, it means that there is a flush in progress or the queue hasn't been started yet select { case q.flushChan <- c: + break case <-ctx.Done(): return ctx.Err() case <-q.ctxRun.Done(): diff --git a/modules/setting/cache.go b/modules/setting/cache.go index cdc7e1a971..519a236599 100644 --- a/modules/setting/cache.go +++ b/modules/setting/cache.go @@ -53,6 +53,7 @@ func loadCacheFrom(rootCfg ConfigProvider) { CacheService.Adapter = sec.Key("ADAPTER").In("memory", []string{"memory", "redis", "memcache", "twoqueue"}) switch CacheService.Adapter { case "memory": + break case "redis", "memcache": CacheService.Conn = strings.Trim(sec.Key("HOST").String(), "\" ") case "twoqueue": diff --git a/modules/setting/incoming_email.go b/modules/setting/incoming_email.go index a890a4a328..47fc2e560d 100644 --- a/modules/setting/incoming_email.go +++ b/modules/setting/incoming_email.go @@ -82,6 +82,7 @@ func checkReplyToAddress() error { case 0: return fmt.Errorf("%s must appear in the user part of the address (before the @)", IncomingEmail.TokenPlaceholder) case 1: + break default: return fmt.Errorf("%s must appear only once", IncomingEmail.TokenPlaceholder) } diff --git a/modules/setting/mailer.go b/modules/setting/mailer.go index b43484a90f..a84758c505 100644 --- a/modules/setting/mailer.go +++ b/modules/setting/mailer.go @@ -235,6 +235,7 @@ func loadMailerFrom(rootCfg ConfigProvider) { } } case "dummy": // just mention and do nothing + break } if MailService.From != "" { diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 693ef90d65..a6235c37ba 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -229,6 +229,7 @@ func HTMLFormat(s string, rawArgs ...any) template.HTML { switch v := v.(type) { case nil, bool, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64, template.HTML: // for most basic types (including template.HTML which is safe), just do nothing and use it + break case string: args[i] = template.HTMLEscapeString(v) case fmt.Stringer: diff --git a/modules/templates/util_date.go b/modules/templates/util_date.go index 839d2701ef..982a1b8050 100644 --- a/modules/templates/util_date.go +++ b/modules/templates/util_date.go @@ -75,6 +75,7 @@ func anyToTime(any any) (t time.Time, isZero bool) { switch v := any.(type) { case nil: // it is zero + break case *time.Time: if v != nil { t = *v diff --git a/modules/translation/i18n/localestore.go b/modules/translation/i18n/localestore.go index fc27c75d13..89361088a4 100644 --- a/modules/translation/i18n/localestore.go +++ b/modules/translation/i18n/localestore.go @@ -145,6 +145,7 @@ func (l *locale) LookupPluralByForm(trKey string, pluralForm PluralFormIndex) st suffix = PluralFormSeparator + "many" case PluralFormOther: // No suffix for the "other" string. + break default: log.Error("Invalid plural form index %d", pluralForm) return "" @@ -248,6 +249,7 @@ func PrepareArgsForHTML(trArgs ...any) []any { switch v := v.(type) { case nil, bool, int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, float32, float64, template.HTML: // for most basic types (including template.HTML which is safe), just do nothing and use it + break case string: args[i] = template.HTMLEscapeString(v) case fmt.Stringer: diff --git a/modules/translation/localeiter/utils.go b/modules/translation/localeiter/utils.go index de398258e2..cda20df1bb 100644 --- a/modules/translation/localeiter/utils.go +++ b/modules/translation/localeiter/utils.go @@ -56,6 +56,7 @@ func iterateMessagesNextInner(onMsgid func(string, string, string) error, data m pluralSuffix = key case "other": // do nothing + break default: realKey = fullKey } @@ -71,6 +72,7 @@ func iterateMessagesNextInner(onMsgid func(string, string, string) error, data m case nil: // do nothing + break default: return fmt.Errorf("Unexpected JSON type: %s - %T", fullKey, value) diff --git a/routers/api/packages/chef/auth.go b/routers/api/packages/chef/auth.go index 7263cf13bb..62523df02d 100644 --- a/routers/api/packages/chef/auth.go +++ b/routers/api/packages/chef/auth.go @@ -141,6 +141,7 @@ func getSignVersion(req *http.Request) (string, error) { switch m[1] { case "1.0", "1.1", "1.2", "1.3": + break default: return "", util.NewInvalidArgumentErrorf("unsupported version") } diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index e182f207f9..5f24f44f90 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -176,6 +176,7 @@ func Search(ctx *context.APIContext) { opts.Mirror = optional.Some(false) opts.Collaborate = optional.Some(true) case "": + break default: ctx.Error(http.StatusUnprocessableEntity, "", fmt.Errorf("Invalid search mode: \"%s\"", mode)) return diff --git a/routers/web/admin/diagnosis.go b/routers/web/admin/diagnosis.go index 8b0ec45214..abd35448f0 100644 --- a/routers/web/admin/diagnosis.go +++ b/routers/web/admin/diagnosis.go @@ -54,7 +54,9 @@ func MonitorDiagnosis(ctx *context.Context) { select { case <-time.After(time.Duration(seconds) * time.Second): + break case <-ctx.Done(): + break } pprof.StopCPUProfile() trace.Stop() diff --git a/routers/web/admin/queue_tester.go b/routers/web/admin/queue_tester.go index 831947fe41..9bcd61592d 100644 --- a/routers/web/admin/queue_tester.go +++ b/routers/web/admin/queue_tester.go @@ -34,7 +34,9 @@ func initTestQueueOnce() { for range t { select { case <-graceful.GetManager().ShutdownContext().Done(): + break case <-time.After(5 * time.Second): + break } } return nil @@ -56,6 +58,7 @@ func initTestQueueOnce() { for { select { case <-ctx.Done(): + break case <-time.After(500 * time.Millisecond): if adding { if testQueue.GetQueueItemNumber() == qs.Length { diff --git a/routers/web/auth/oauth.go b/routers/web/auth/oauth.go index 22d8c7b846..a53e718aa9 100644 --- a/routers/web/auth/oauth.go +++ b/routers/web/auth/oauth.go @@ -1418,6 +1418,7 @@ func generateCodeChallenge(ctx *context.Context, provider string) (codeChallenge case *openidConnect.Provider, *fitbit.Provider, *zoom.Provider: // those providers forward the `code_verifier` // a code_challenge can be generated + break } codeVerifier := util.CryptoRandomString(util.RandomStringHigh) diff --git a/routers/web/repo/repo.go b/routers/web/repo/repo.go index eca4c5f5e7..6b6ec55720 100644 --- a/routers/web/repo/repo.go +++ b/routers/web/repo/repo.go @@ -634,6 +634,7 @@ func SearchRepo(ctx *context.Context) { opts.Mirror = optional.Some(false) opts.Collaborate = optional.Some(true) case "": + break default: ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Invalid search mode: \"%s\"", mode)) return diff --git a/routers/web/user/home.go b/routers/web/user/home.go index 3bd118e06c..9c40236475 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -511,8 +511,6 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) { } switch filterMode { - case issues_model.FilterModeAll: - case issues_model.FilterModeYourRepositories: case issues_model.FilterModeAssign: opts.AssigneeID = ctx.Doer.ID case issues_model.FilterModeCreate: @@ -846,7 +844,7 @@ func getUserIssueStats(ctx *context.Context, ctxUser *user_model.User, filterMod openClosedOpts := opts.Copy() switch filterMode { case issues_model.FilterModeAll: - // no-op + break case issues_model.FilterModeYourRepositories: openClosedOpts.AllPublic = false case issues_model.FilterModeAssign: diff --git a/routers/web/user/package.go b/routers/web/user/package.go index 2862c6684b..9a77af0bb2 100644 --- a/routers/web/user/package.go +++ b/routers/web/user/package.go @@ -180,8 +180,6 @@ func ViewPackageVersion(ctx *context.Context) { ctx.Data["PackageRegistryHost"] = setting.Packages.RegistryHost switch pd.Package.Type { - case packages_model.TypeContainer: - case packages_model.TypeAlpine: branches := make(container.Set[string]) repositories := make(container.Set[string]) diff --git a/services/actions/job_emitter.go b/services/actions/job_emitter.go index a7f4273338..02ad9d66f5 100644 --- a/services/actions/job_emitter.go +++ b/services/actions/job_emitter.go @@ -85,6 +85,7 @@ func checkJobsOfRun(ctx context.Context, runID int64, recursionCount int) error case behaviourExecuteJob: // Intentional blank case -- proceed with updating the status of the job to waiting. + break case behaviourIgnoreJob: // Skip updating this job's status to waiting, continue with other jobs in the run. diff --git a/services/convert/activitypub_user_action.go b/services/convert/activitypub_user_action.go index 9c62e6f25c..b08eaa14c7 100644 --- a/services/convert/activitypub_user_action.go +++ b/services/convert/activitypub_user_action.go @@ -164,13 +164,6 @@ func ActionToForgeUserActivity(ctx context.Context, action *activities_model.Act renderIssue(action.Comment.Issue), renderedComment, ) - case activities_model.ActionMirrorSyncPush: - case activities_model.ActionMirrorSyncCreate: - case activities_model.ActionMirrorSyncDelete: - case activities_model.ActionPublishRelease: - case activities_model.ActionPullReviewDismissed: - case activities_model.ActionPullRequestReadyForReview: - case activities_model.ActionAutoMergePullRequest: } return makeUserActivity("performed an unrecognised action: %s", action.OpType.String()) diff --git a/services/mailer/incoming/incoming.go b/services/mailer/incoming/incoming.go index b1b9191df3..39d1554083 100644 --- a/services/mailer/incoming/incoming.go +++ b/services/mailer/incoming/incoming.go @@ -69,6 +69,7 @@ func Init(ctx context.Context) error { case <-ctx.Done(): return case <-time.NewTimer(10 * time.Second).C: + break } } } @@ -123,6 +124,7 @@ func processIncomingEmails(ctx context.Context) error { case <-ctx.Done(): return nil case <-time.NewTimer(time.Second).C: + break } } } diff --git a/services/migrations/github.go b/services/migrations/github.go index ed419ed444..7cfb626a15 100644 --- a/services/migrations/github.go +++ b/services/migrations/github.go @@ -182,6 +182,7 @@ func (g *GithubDownloaderV3) waitAndPickClient() { timer.Stop() return case <-timer.C: + break } err := g.RefreshRate() diff --git a/services/pull/patch_unmerged.go b/services/pull/patch_unmerged.go index caa0318c48..209674ef82 100644 --- a/services/pull/patch_unmerged.go +++ b/services/pull/patch_unmerged.go @@ -170,6 +170,7 @@ func unmergedFiles(ctx context.Context, tmpBasePath string, unmerged chan *unmer switch line.stage { case 0: // Should not happen as this represents successfully merged file - we will tolerate and ignore though + break case 1: if next.stage1 != nil || next.stage2 != nil || next.stage3 != nil { // We need to handle the unstaged file stage1,stage2,stage3 diff --git a/services/repository/gitgraph/parser.go b/services/repository/gitgraph/parser.go index 3c98e66273..fcbc666f7e 100644 --- a/services/repository/gitgraph/parser.go +++ b/services/repository/gitgraph/parser.go @@ -184,7 +184,7 @@ func (parser *Parser) ParseGlyphs(glyphs []byte) { case '-': parser.setLeftFlow(i) case ' ': - // no-op + break default: parser.newFlow(i) } diff --git a/services/task/migrate.go b/services/task/migrate.go index a9f76299fd..2a2a8b3668 100644 --- a/services/task/migrate.go +++ b/services/task/migrate.go @@ -108,6 +108,7 @@ func runMigrateTask(ctx context.Context, t *admin_model.Task) (err error) { for { select { case <-time.After(2 * time.Second): + break case <-ctx.Done(): return }