Skip to content

Commit 2ed61c6

Browse files
committed
Fixesg
1 parent 983ed07 commit 2ed61c6

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

.golangci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ linters:
6767
- all
6868
- -QF1001
6969
- -QF1003
70+
- -SA1019
7071
- -SA6005
7172
- -SA9003
7273
- -ST1000

internal/execute/tsctestrunner_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (test *tscInput) run(t *testing.T, scenario string) {
8484
var nonIncrementalSys *testSys
8585
commandLineArgs := core.IfElse(do.commandLineArgs == nil, test.commandLineArgs, do.commandLineArgs)
8686
wg.Queue(func() {
87-
baselineBuilder.WriteString(fmt.Sprintf("\n\nEdit [%d]:: %s\n", index, do.caption))
87+
fmt.Fprintf(baselineBuilder, "\n\nEdit [%d]:: %s\n", index, do.caption)
8888
if do.edit != nil {
8989
do.edit(sys)
9090
}
@@ -113,10 +113,10 @@ func (test *tscInput) run(t *testing.T, scenario string) {
113113

114114
diff := getDiffForIncremental(sys, nonIncrementalSys)
115115
if diff != "" {
116-
baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s\n", core.IfElse(do.expectedDiff == "", "!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!", do.expectedDiff)))
116+
fmt.Fprintf(baselineBuilder, "\n\nDiff:: %s\n", core.IfElse(do.expectedDiff == "", "!!! Unexpected diff, please review and either fix or write explanation as expectedDiff !!!", do.expectedDiff))
117117
baselineBuilder.WriteString(diff)
118118
} else if do.expectedDiff != "" {
119-
baselineBuilder.WriteString(fmt.Sprintf("\n\nDiff:: %s !!! Diff not found but explanation present, please review and remove the explanation !!!\n", do.expectedDiff))
119+
fmt.Fprintf(baselineBuilder, "\n\nDiff:: %s !!! Diff not found but explanation present, please review and remove the explanation !!!\n", do.expectedDiff)
120120
}
121121
}
122122
baseline.Run(t, strings.ReplaceAll(test.subScenario, " ", "-")+".js", baselineBuilder.String(), baseline.Options{Subfolder: filepath.Join(test.getBaselineSubFolder(), scenario)})

internal/fourslash/baselineutil.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ func (t *textWithContext) add(detail *baselineDetail) {
420420
if t.isLibFile {
421421
t.newContent.WriteString("--- (line: --) skipped ---\n")
422422
} else {
423-
t.newContent.WriteString(fmt.Sprintf("--- (line: %v) skipped ---\n", locationLineIndex-t.nLinesContext+1))
423+
fmt.Fprintf(t.newContent, "--- (line: %v) skipped ---\n", locationLineIndex-t.nLinesContext+1)
424424
}
425425
t.newContent.WriteString(t.sliceOfContent(
426426
t.getIndex(t.lineStarts.LineStarts[locationLineIndex-t.nLinesContext+1]),
@@ -459,20 +459,20 @@ func (t *textWithContext) sliceOfContent(start *int, end *int) string {
459459
return t.content[*start:*end]
460460
}
461461

462-
func (t *textWithContext) getIndex(i interface{}) *int {
463-
switch i.(type) {
462+
func (t *textWithContext) getIndex(i any) *int {
463+
switch i := i.(type) {
464464
case *int:
465-
return i.(*int)
465+
return i
466466
case int:
467-
return ptrTo(i.(int))
467+
return ptrTo(i)
468468
case core.TextPos:
469-
return ptrTo(int(i.(core.TextPos)))
469+
return ptrTo(int(i))
470470
case *core.TextPos:
471-
return ptrTo(int(*i.(*core.TextPos)))
471+
return ptrTo(int(*i))
472472
case lsproto.Position:
473-
return t.getIndex(t.converters.LineAndCharacterToPosition(t, i.(lsproto.Position)))
473+
return t.getIndex(t.converters.LineAndCharacterToPosition(t, i))
474474
case *lsproto.Position:
475-
return t.getIndex(t.converters.LineAndCharacterToPosition(t, *i.(*lsproto.Position)))
475+
return t.getIndex(t.converters.LineAndCharacterToPosition(t, *i))
476476
}
477477
panic(fmt.Sprintf("getIndex: unsupported type %T", i))
478478
}

internal/incremental/snapshot.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,10 @@ func diagnosticToStringBuilder(diagnostic *ast.Diagnostic, file *ast.SourceFile,
293293
)))
294294
}
295295
if diagnostic.File() != nil {
296-
builder.WriteString(fmt.Sprintf("(%d,%d): ", diagnostic.Pos(), diagnostic.Len()))
296+
fmt.Fprintf(builder, "(%d,%d): ", diagnostic.Pos(), diagnostic.Len())
297297
}
298298
builder.WriteString(diagnostic.Category().Name())
299-
builder.WriteString(fmt.Sprintf("%d: ", diagnostic.Code()))
299+
fmt.Fprintf(builder, "%d: ", diagnostic.Code())
300300
builder.WriteString(diagnostic.Message())
301301
for _, chain := range diagnostic.MessageChain() {
302302
diagnosticToStringBuilder(chain, file, builder)

internal/tsoptions/tsconfigparsing.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ type CommandLineOptionNameMap map[string]*CommandLineOption
540540
func (m CommandLineOptionNameMap) Get(name string) *CommandLineOption {
541541
opt, ok := m[name]
542542
if !ok {
543-
opt, _ = m[strings.ToLower(name)]
543+
opt = m[strings.ToLower(name)]
544544
}
545545
return opt
546546
}

0 commit comments

Comments
 (0)