Skip to content

Commit e4b5fc7

Browse files
committed
style: lint fix
1 parent 29b952a commit e4b5fc7

File tree

7 files changed

+8
-33
lines changed

7 files changed

+8
-33
lines changed

adapters/golang/parser.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,3 @@ func (a *Adapter) createSingleComment(fset *token.FileSet, c *ast.Comment, file,
197197
Type: cType,
198198
}
199199
}
200-
201-
// createCommentFromGroup is deprecated
202-
func (a *Adapter) createCommentFromGroup(fset *token.FileSet, cg *ast.CommentGroup, file, symbol string) *domain.Comment {
203-
return nil
204-
}
205-
206-
// createComment is deprecated
207-
func (a *Adapter) createComment(fset *token.FileSet, c *ast.Comment, file, symbol string) *domain.Comment {
208-
return nil
209-
}

adapters/rust/extractor.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,7 @@ func isEmptyComment(content string) bool {
104104
return strings.TrimSpace(strings.TrimPrefix(trimmed, "//")) == ""
105105
case strings.HasPrefix(trimmed, "/*"):
106106
inner := strings.TrimPrefix(trimmed, "/*")
107-
if strings.HasSuffix(inner, "*/") {
108-
inner = strings.TrimSuffix(inner, "*/")
109-
}
107+
inner = strings.TrimSuffix(inner, "*/")
110108
return strings.TrimSpace(inner) == ""
111109
default:
112110
return strings.TrimSpace(trimmed) == ""

cmd/codei18n/convert.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"fmt"
5-
"io/ioutil"
65
"os"
76
"path/filepath"
87
"sort"
@@ -113,7 +112,7 @@ func runConvert() {
113112

114113
func processFile(file string, adapter core.LanguageAdapter, store *mapping.Store, cfg *config.Config) {
115114
// Read file
116-
src, err := ioutil.ReadFile(file)
115+
src, err := os.ReadFile(file)
117116
if err != nil {
118117
log.Error("读取文件 %s 失败: %v", file, err)
119118
return
@@ -281,7 +280,7 @@ func processFile(file string, adapter core.LanguageAdapter, store *mapping.Store
281280
return
282281
}
283282

284-
if err := ioutil.WriteFile(file, []byte(newSrc), 0644); err != nil {
283+
if err := os.WriteFile(file, []byte(newSrc), 0644); err != nil {
285284
log.Error("写入文件 %s 失败: %v", file, err)
286285
} else {
287286
log.Success("已处理 %s", file)

cmd/codei18n/hook.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package main
22

33
import (
4-
"io/ioutil"
54
"os"
65
"path/filepath"
76

@@ -91,7 +90,7 @@ echo "CodeI18n: Done."
9190
exit 0
9291
`
9392

94-
if err := ioutil.WriteFile(hookPath, []byte(hookContent), 0755); err != nil {
93+
if err := os.WriteFile(hookPath, []byte(hookContent), 0755); err != nil {
9594
log.Fatal("安装 hook 失败: %v", err)
9695
}
9796

core/utils/id.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,11 @@ func NormalizeCommentText(text string) string {
3434
t := strings.TrimSpace(text)
3535

3636
// Remove single line markers
37-
if strings.HasPrefix(t, "//") {
38-
t = strings.TrimPrefix(t, "//")
39-
}
37+
t = strings.TrimPrefix(t, "//")
4038

4139
// Remove block markers
42-
if strings.HasPrefix(t, "/*") {
43-
t = strings.TrimPrefix(t, "/*")
44-
t = strings.TrimSuffix(t, "*/")
45-
}
40+
t = strings.TrimPrefix(t, "/*")
41+
t = strings.TrimSuffix(t, "*/")
4642

4743
// Normalize whitespace: replace sequences of whitespace with single space
4844
return strings.Join(strings.Fields(t), " ")

internal/log/logger.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ import (
77
"github.com/fatih/color"
88
)
99

10-
var (
11-
// Standard loggers that write to Stderr
12-
infoLogger = color.New(color.FgCyan).FprintlnFunc()
13-
warnLogger = color.New(color.FgYellow).FprintlnFunc()
14-
errorLogger = color.New(color.FgRed).FprintlnFunc()
15-
debugLogger = color.New(color.FgMagenta).FprintlnFunc()
16-
)
17-
1810
// Info prints an informational message to Stderr
1911
func Info(format string, a ...interface{}) {
2012
fmt.Fprintf(os.Stderr, "[INFO] "+format+"\n", a...)

tests/integration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ func TestIncrementalScan(t *testing.T) {
146146
f, err := os.OpenFile(filePath, os.O_APPEND|os.O_WRONLY, 0644)
147147
require.NoError(t, err)
148148
_, err = f.WriteString("\n// New Comment\n")
149+
require.NoError(t, err)
149150
f.Close()
150151

151152
// 5. Scan again

0 commit comments

Comments
 (0)