style: reenable switch check
This commit is contained in:
parent
adf4dcdbbf
commit
8322882265
|
@ -43,7 +43,6 @@ linters-settings:
|
|||
gocritic:
|
||||
disabled-checks:
|
||||
- ifElseChain
|
||||
- singleCaseSwitch # Every time this occurred in the code, there was no other way.
|
||||
revive:
|
||||
severity: error
|
||||
rules:
|
||||
|
|
|
@ -58,6 +58,7 @@ func Cell2Int64(val xorm.Cell) int64 {
|
|||
|
||||
v, _ := strconv.ParseInt(string((*val).([]uint8)), 10, 64)
|
||||
return v
|
||||
}
|
||||
default:
|
||||
return (*val).(int64)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -235,8 +235,7 @@ func (cfg *ActionsConfig) ToDB() ([]byte, error) {
|
|||
|
||||
// BeforeSet is invoked from XORM before setting the value of a field of this object.
|
||||
func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) {
|
||||
switch colName {
|
||||
case "type":
|
||||
if colName == "type" {
|
||||
switch unit.Type(db.Cell2Int64(val)) {
|
||||
case unit.TypeExternalWiki:
|
||||
r.Config = new(ExternalWikiConfig)
|
||||
|
|
|
@ -649,8 +649,7 @@ func matchReleaseEvent(payload *api.ReleasePayload, evt *jobparser.Event) bool {
|
|||
// unpublished, created, deleted, prereleased, released
|
||||
|
||||
action := payload.Action
|
||||
switch action {
|
||||
case api.HookReleaseUpdated:
|
||||
if action == api.HookReleaseUpdated {
|
||||
action = "edited"
|
||||
}
|
||||
for _, val := range vals {
|
||||
|
@ -686,8 +685,7 @@ func matchPackageEvent(payload *api.PackagePayload, evt *jobparser.Event) bool {
|
|||
// updated
|
||||
|
||||
action := payload.Action
|
||||
switch action {
|
||||
case api.HookPackageCreated:
|
||||
if action == api.HookPackageCreated {
|
||||
action = "published"
|
||||
}
|
||||
for _, val := range vals {
|
||||
|
|
|
@ -16,8 +16,9 @@ func GetItemByType(typ ap.ActivityVocabularyType) (ap.Item, error) {
|
|||
switch typ {
|
||||
case RepositoryType:
|
||||
return RepositoryNew(""), nil
|
||||
}
|
||||
default:
|
||||
return ap.GetItemByType(typ)
|
||||
}
|
||||
}
|
||||
|
||||
// JSONUnmarshalerFn is the function that will load the data from a fastjson.Value into an Item
|
||||
|
@ -28,8 +29,9 @@ func JSONUnmarshalerFn(typ ap.ActivityVocabularyType, val *fastjson.Value, i ap.
|
|||
return OnRepository(i, func(r *Repository) error {
|
||||
return JSONLoadRepository(val, r)
|
||||
})
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// NotEmpty is the function that checks if an object is empty
|
||||
|
@ -44,6 +46,7 @@ func NotEmpty(i ap.Item) bool {
|
|||
return false
|
||||
}
|
||||
return ap.NotEmpty(r.Actor)
|
||||
}
|
||||
default:
|
||||
return ap.NotEmpty(i)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ func (g *GitHubCalloutTransformer) Transform(node *ast.Document, reader text.Rea
|
|||
return ast.WalkContinue, nil
|
||||
}
|
||||
|
||||
switch v := n.(type) {
|
||||
case *ast.Blockquote:
|
||||
if v, ok := n.(*ast.Blockquote); ok {
|
||||
if v.ChildCount() == 0 {
|
||||
return ast.WalkContinue, nil
|
||||
}
|
||||
|
@ -91,7 +90,6 @@ func (g *GitHubCalloutTransformer) Transform(node *ast.Document, reader text.Rea
|
|||
firstParagraph.Parent().InsertBefore(firstParagraph.Parent(), firstParagraph, attentionParagraph)
|
||||
firstParagraph.RemoveChild(firstParagraph, firstTextNode)
|
||||
firstParagraph.RemoveChild(firstParagraph, secondTextNode)
|
||||
firstParagraph.RemoveChild(firstParagraph, thirdTextNode)
|
||||
}
|
||||
return ast.WalkContinue, nil
|
||||
})
|
||||
|
|
|
@ -23,8 +23,7 @@ func (g *GitHubLegacyCalloutTransformer) Transform(node *ast.Document, reader te
|
|||
return ast.WalkContinue, nil
|
||||
}
|
||||
|
||||
switch v := n.(type) {
|
||||
case *ast.Blockquote:
|
||||
if v, ok := n.(*ast.Blockquote); ok {
|
||||
if v.ChildCount() == 0 {
|
||||
return ast.WalkContinue, nil
|
||||
}
|
||||
|
|
|
@ -98,8 +98,7 @@ func getLicensePlaceholder(name string) *licensePlaceholder {
|
|||
|
||||
// Some special placeholders for specific licenses.
|
||||
// It's unsafe to apply them to all licenses.
|
||||
switch name {
|
||||
case "0BSD":
|
||||
if name == "0BSD" {
|
||||
return &licensePlaceholder{
|
||||
Owner: []string{"AUTHOR"},
|
||||
Email: []string{"EMAIL"},
|
||||
|
|
|
@ -122,8 +122,7 @@ func (p *RedisProvider) Init(maxlifetime int64, configs string) (err error) {
|
|||
uri := nosql.ToRedisURI(configs)
|
||||
|
||||
for k, v := range uri.Query() {
|
||||
switch k {
|
||||
case "prefix":
|
||||
if k == "prefix" {
|
||||
p.prefix = v[0]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,8 +13,9 @@ func (taskType TaskType) Name() string {
|
|||
switch taskType {
|
||||
case TaskTypeMigrateRepo:
|
||||
return "Migrate Repository"
|
||||
}
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// TaskStatus defines task status
|
||||
|
|
|
@ -83,13 +83,10 @@ func (entry *Workflow) Dispatch(ctx context.Context, inputGetter InputValueGette
|
|||
}
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
switch input.Type {
|
||||
case "boolean":
|
||||
} else if input.Type == "boolean" {
|
||||
// Since "boolean" inputs are rendered as a checkbox in html, the value inside the form is "on"
|
||||
val = strconv.FormatBool(val == "on")
|
||||
}
|
||||
}
|
||||
inputs[key] = val
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ func (h *UnsubscribeHandler) Handle(ctx context.Context, _ *MailContent, doer *u
|
|||
}
|
||||
|
||||
return issues_model.CreateOrUpdateIssueWatch(ctx, doer.ID, issue.ID, false)
|
||||
}
|
||||
|
||||
default:
|
||||
return fmt.Errorf("unsupported unsubscribe reference: %v", ref)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,8 +160,7 @@ func (dc dingtalkConvertor) PullRequest(p *api.PullRequestPayload) (DingtalkPayl
|
|||
// Review implements PayloadConvertor Review method
|
||||
func (dc dingtalkConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (DingtalkPayload, error) {
|
||||
var text, title string
|
||||
switch p.Action {
|
||||
case api.HookIssueReviewed:
|
||||
if p.Action == api.HookIssueReviewed {
|
||||
action, err := parseHookPullRequestEventType(event)
|
||||
if err != nil {
|
||||
return DingtalkPayload{}, err
|
||||
|
|
|
@ -215,8 +215,7 @@ func (d discordConvertor) PullRequest(p *api.PullRequestPayload) (DiscordPayload
|
|||
func (d discordConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (DiscordPayload, error) {
|
||||
var text, title string
|
||||
var color int
|
||||
switch p.Action {
|
||||
case api.HookIssueReviewed:
|
||||
if p.Action == api.HookIssueReviewed {
|
||||
action, err := parseHookPullRequestEventType(event)
|
||||
if err != nil {
|
||||
return DiscordPayload{}, err
|
||||
|
|
|
@ -237,8 +237,7 @@ func (m matrixConvertor) Review(p *api.PullRequestPayload, event webhook_module.
|
|||
repoLink := htmlLinkFormatter(p.Repository.HTMLURL, p.Repository.FullName)
|
||||
var text string
|
||||
|
||||
switch p.Action {
|
||||
case api.HookIssueReviewed:
|
||||
if p.Action == api.HookIssueReviewed {
|
||||
action, err := parseHookPullRequestEventType(event)
|
||||
if err != nil {
|
||||
return MatrixPayload{}, err
|
||||
|
|
|
@ -225,8 +225,7 @@ func (m msteamsConvertor) PullRequest(p *api.PullRequestPayload) (MSTeamsPayload
|
|||
func (m msteamsConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (MSTeamsPayload, error) {
|
||||
var text, title string
|
||||
var color int
|
||||
switch p.Action {
|
||||
case api.HookIssueReviewed:
|
||||
if p.Action == api.HookIssueReviewed {
|
||||
action, err := parseHookPullRequestEventType(event)
|
||||
if err != nil {
|
||||
return MSTeamsPayload{}, err
|
||||
|
|
|
@ -289,8 +289,7 @@ func (s slackConvertor) Review(p *api.PullRequestPayload, event webhook_module.H
|
|||
repoLink := SlackLinkFormatter(p.Repository.HTMLURL, p.Repository.FullName)
|
||||
var text string
|
||||
|
||||
switch p.Action {
|
||||
case api.HookIssueReviewed:
|
||||
if p.Action == api.HookIssueReviewed {
|
||||
action, err := parseHookPullRequestEventType(event)
|
||||
if err != nil {
|
||||
return SlackPayload{}, err
|
||||
|
|
|
@ -164,8 +164,7 @@ func (t telegramConvertor) PullRequest(p *api.PullRequestPayload) (TelegramPaylo
|
|||
// Review implements PayloadConvertor Review method
|
||||
func (t telegramConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (TelegramPayload, error) {
|
||||
var text, attachmentText string
|
||||
switch p.Action {
|
||||
case api.HookIssueReviewed:
|
||||
if p.Action == api.HookIssueReviewed {
|
||||
action, err := parseHookPullRequestEventType(event)
|
||||
if err != nil {
|
||||
return TelegramPayload{}, err
|
||||
|
|
|
@ -154,8 +154,7 @@ func (wc wechatworkConvertor) PullRequest(p *api.PullRequestPayload) (Wechatwork
|
|||
// Review implements PayloadConvertor Review method
|
||||
func (wc wechatworkConvertor) Review(p *api.PullRequestPayload, event webhook_module.HookEventType) (WechatworkPayload, error) {
|
||||
var text, title string
|
||||
switch p.Action {
|
||||
case api.HookIssueReviewed:
|
||||
if p.Action == api.HookIssueReviewed {
|
||||
action, err := parseHookPullRequestEventType(event)
|
||||
if err != nil {
|
||||
return WechatworkPayload{}, err
|
||||
|
|
Loading…
Reference in New Issue