Skip to content

Commit 83267b5

Browse files
committed
fix: resolve lint errors (intrange, octalLiteral, importShadow)
- Use range-over-integer loops (Go 1.22+) in paste parsers - Use 0o644 octal literal style in tests - Rename local 'paths' to 'filePaths' to avoid shadowing pkg/paths import Assisted-By: cagent
1 parent d42fe9e commit 83267b5

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

pkg/tui/components/editor/editor.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,10 +1444,10 @@ func (e *editor) SendContent() tea.Cmd {
14441444

14451445
func (e *editor) handlePaste(content string) bool {
14461446
// First, try to parse as file paths (drag-and-drop)
1447-
paths := ParsePastedFiles(content)
1448-
if len(paths) > 0 && e.allFilesValid(paths) {
1447+
filePaths := ParsePastedFiles(content)
1448+
if len(filePaths) > 0 && e.allFilesValid(filePaths) {
14491449
// All paths are valid files with supported types
1450-
for _, path := range paths {
1450+
for _, path := range filePaths {
14511451
if err := e.AttachFile(path); err != nil {
14521452
slog.Warn("failed to attach dropped file", "path", path, "error", err)
14531453
}
@@ -1483,12 +1483,12 @@ func (e *editor) handlePaste(content string) bool {
14831483
}
14841484

14851485
// allFilesValid checks if all paths exist, are regular files (not dirs/symlinks), and have supported types.
1486-
func (e *editor) allFilesValid(paths []string) bool {
1487-
if len(paths) == 0 {
1486+
func (e *editor) allFilesValid(filePaths []string) bool {
1487+
if len(filePaths) == 0 {
14881488
return false
14891489
}
14901490

1491-
for _, path := range paths {
1491+
for _, path := range filePaths {
14921492
info, err := validateFilePath(path)
14931493
if err != nil {
14941494
return false

pkg/tui/components/editor/paste.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func windowsTerminalParsePastedFiles(s string) []string {
9898
inQuotes = false
9999
)
100100

101-
for i := 0; i < len(s); i++ {
101+
for i := range len(s) {
102102
ch := s[i]
103103

104104
switch {
@@ -149,7 +149,7 @@ func unixParsePastedFiles(s string) []string {
149149
escaped = false
150150
)
151151

152-
for i := 0; i < len(s); i++ {
152+
for i := range len(s) {
153153
ch := s[i]
154154

155155
switch {

pkg/tui/components/editor/paste_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,10 @@ func TestParsePastedFilesWithRealFiles(t *testing.T) {
423423
file2 := filepath.Join(tmpDir, "test2.jpg")
424424

425425
// Create files
426-
if err := os.WriteFile(file1, []byte("fake png"), 0644); err != nil {
426+
if err := os.WriteFile(file1, []byte("fake png"), 0o644); err != nil {
427427
t.Fatal(err)
428428
}
429-
if err := os.WriteFile(file2, []byte("fake jpg"), 0644); err != nil {
429+
if err := os.WriteFile(file2, []byte("fake jpg"), 0o644); err != nil {
430430
t.Fatal(err)
431431
}
432432

@@ -453,7 +453,7 @@ func TestValidateFilePath(t *testing.T) {
453453
tmpDir := t.TempDir()
454454

455455
regularFile := filepath.Join(tmpDir, "regular.txt")
456-
if err := os.WriteFile(regularFile, []byte("content"), 0644); err != nil {
456+
if err := os.WriteFile(regularFile, []byte("content"), 0o644); err != nil {
457457
t.Fatal(err)
458458
}
459459

0 commit comments

Comments
 (0)