@@ -36,7 +36,7 @@ func TestReplaceInFile_ReadOnlyFile(t *testing.T) {
3636 if err := os .Chmod (filePath , 0444 ); err != nil {
3737 t .Fatalf ("Failed to chmod: %v" , err )
3838 }
39- defer os .Chmod (filePath , 0644 ) // Restore permissions for cleanup
39+ defer func () { _ = os .Chmod (filePath , 0644 ) }( ) // Restore permissions for cleanup
4040
4141 config := Config {
4242 Search : "target" ,
@@ -61,7 +61,7 @@ func TestReplaceInFile_DryRunReadOnly(t *testing.T) {
6161 if err := os .Chmod (filePath , 0444 ); err != nil {
6262 t .Fatalf ("Failed to chmod: %v" , err )
6363 }
64- defer os .Chmod (filePath , 0644 )
64+ defer func () { _ = os .Chmod (filePath , 0644 ) }( )
6565
6666 config := Config {
6767 Search : "target" ,
@@ -152,7 +152,7 @@ func TestReplaceInDirectory_NoReadPermission(t *testing.T) {
152152 if err := os .Chmod (subDir , 0000 ); err != nil {
153153 t .Fatalf ("Failed to chmod: %v" , err )
154154 }
155- defer os .Chmod (subDir , 0755 ) // Restore for cleanup
155+ defer func () { _ = os .Chmod (subDir , 0755 ) }( ) // Restore for cleanup
156156
157157 config := Config {
158158 Search : "test" ,
@@ -226,7 +226,7 @@ func TestReplaceInFile_ConcurrentModification(t *testing.T) {
226226 // This is a race condition we want to detect
227227 go func () {
228228 // Modify file after a brief delay
229- os .WriteFile (filePath , []byte ("modified content\n " ), 0644 )
229+ _ = os .WriteFile (filePath , []byte ("modified content\n " ), 0644 )
230230 }()
231231
232232 // Try to replace
@@ -285,7 +285,9 @@ func TestReplaceInDirectory_SkipsSubdirectories(t *testing.T) {
285285 // Create files and subdirectory
286286 createTestFile (t , tmpDir , "file1.txt" , "target\n " )
287287 subDir := filepath .Join (tmpDir , "subdir" )
288- os .Mkdir (subDir , 0755 )
288+ if err := os .Mkdir (subDir , 0755 ); err != nil {
289+ t .Fatal (err )
290+ }
289291 createTestFile (t , subDir , "file2.txt" , "target\n " )
290292
291293 config := Config {
@@ -422,8 +424,10 @@ func TestReplaceInDirectory_PartialFailure(t *testing.T) {
422424
423425 badPath := filepath .Join (tmpDir , "bad.txt" )
424426 createTestFile (t , tmpDir , "bad.txt" , "target\n " )
425- os .Chmod (badPath , 0000 )
426- defer os .Chmod (badPath , 0644 )
427+ if err := os .Chmod (badPath , 0000 ); err != nil {
428+ t .Fatal (err )
429+ }
430+ defer func () { _ = os .Chmod (badPath , 0644 ) }()
427431
428432 config := Config {
429433 Search : "target" ,
@@ -449,7 +453,9 @@ func TestReplaceInDirectories_MixedValidInvalid(t *testing.T) {
449453 defer cleanupTestDir (t , tmpDir )
450454
451455 validDir := filepath .Join (tmpDir , "valid" )
452- os .Mkdir (validDir , 0755 )
456+ if err := os .Mkdir (validDir , 0755 ); err != nil {
457+ t .Fatal (err )
458+ }
453459 createTestFile (t , validDir , "test.txt" , "target\n " )
454460
455461 config := Config {
0 commit comments