Skip to content

Commit c39fdec

Browse files
fix: address remaining golangci-lint QF1003 and unconvert issues
- Convert if-else chains to tagged switch statements in member_ordering.go (2 instances) - Convert if-else chain to tagged switch in explicit_member_accessibility.go - Remove unnecessary string conversion in explicit_member_accessibility.go These changes address the remaining staticcheck warnings to pass CI.
1 parent 62ca3e6 commit c39fdec

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

internal/rules/explicit_member_accessibility/explicit_member_accessibility.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ func findPublicKeywordRange(ctx rule.RuleContext, node *ast.Node) (core.TextRang
164164
removeEnd = modifiers.Nodes[i+1].Pos()
165165
} else {
166166
// Find next token after public keyword
167-
text := string(ctx.SourceFile.Text())
167+
text := ctx.SourceFile.Text()
168168
for removeEnd < len(text) && (text[removeEnd] == ' ' || text[removeEnd] == '\t') {
169169
removeEnd++
170170
}
@@ -461,12 +461,11 @@ var ExplicitMemberAccessibilityRule = rule.Rule{
461461
hasAccessibility := false
462462
var readonlyNode *ast.Node
463463
for _, mod := range param.Modifiers().Nodes {
464-
if mod.Kind == ast.KindReadonlyKeyword {
464+
switch kind := mod.Kind; kind {
465+
case ast.KindReadonlyKeyword:
465466
hasReadonly = true
466467
readonlyNode = mod
467-
} else if mod.Kind == ast.KindPublicKeyword ||
468-
mod.Kind == ast.KindPrivateKeyword ||
469-
mod.Kind == ast.KindProtectedKeyword {
468+
case ast.KindPublicKeyword, ast.KindPrivateKeyword, ast.KindProtectedKeyword:
470469
hasAccessibility = true
471470
}
472471
}

internal/rules/member_ordering/member_ordering.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,10 @@ func getMemberGroups(node *ast.Node, supportsModifiers bool) []string {
453453

454454
if !supportsModifiers {
455455
groups = append(groups, string(nodeType))
456-
if nodeType == KindReadonlySignature {
456+
switch nt := nodeType; nt {
457+
case KindReadonlySignature:
457458
groups = append(groups, string(KindSignature))
458-
} else if nodeType == KindReadonlyField {
459+
case KindReadonlyField:
459460
groups = append(groups, string(KindField))
460461
}
461462
return groups
@@ -511,9 +512,10 @@ func getMemberGroups(node *ast.Node, supportsModifiers bool) []string {
511512

512513
// Add base member type
513514
groups = append(groups, string(nodeType))
514-
if nodeType == KindReadonlySignature {
515+
switch nt := nodeType; nt {
516+
case KindReadonlySignature:
515517
groups = append(groups, string(KindSignature))
516-
} else if nodeType == KindReadonlyField {
518+
case KindReadonlyField:
517519
groups = append(groups, string(KindField))
518520
}
519521

0 commit comments

Comments
 (0)