diff --git a/pkg/iac/scanners/helm/parser/parser_tar.go b/pkg/iac/scanners/helm/parser/parser_tar.go index 5c073dad9875..4826a16dce07 100644 --- a/pkg/iac/scanners/helm/parser/parser_tar.go +++ b/pkg/iac/scanners/helm/parser/parser_tar.go @@ -81,7 +81,7 @@ func (p *Parser) addTarToFS(archivePath string) (fs.FS, error) { continue } - symlinks[targetPath] = path.Join(filepath.Dir(targetPath), header.Linkname) + symlinks[targetPath] = path.Join(filepath.Dir(targetPath), header.Linkname) // nolint:gosec // virtual file system is used default: return nil, fmt.Errorf("header type %q is not supported", header.Typeflag) } @@ -106,10 +106,10 @@ func (p *Parser) addTarToFS(archivePath string) (fs.FS, error) { } if err := copyFile(tarFS, f, target); err != nil { - f.Close() + _ = f.Close() return nil, fmt.Errorf("copy file error: %w", err) } - f.Close() + _ = f.Close() } if err := tarFS.Remove(archivePath); err != nil { @@ -136,7 +136,7 @@ func copyFile(fsys *memoryfs.FS, src io.Reader, dst string) error { return nil } -func copyDir(fsys *memoryfs.FS, src string, dst string) error { +func copyDir(fsys *memoryfs.FS, src, dst string) error { walkFn := func(filePath string, entry fs.DirEntry, err error) error { if err != nil { return err diff --git a/pkg/iac/scanners/helm/test/parser_test.go b/pkg/iac/scanners/helm/test/parser_test.go index 85a69469fb5d..989590d4268f 100644 --- a/pkg/iac/scanners/helm/test/parser_test.go +++ b/pkg/iac/scanners/helm/test/parser_test.go @@ -114,13 +114,13 @@ func Test_tar_is_chart(t *testing.T) { t.Logf("Running test: %s", test.testName) testPath := filepath.Join("testdata", test.archiveFile) - file, err := os.Open(testPath) - defer func() { _ = file.Close() }() - require.NoError(t, err) - - assert.Equal(t, test.isHelmChart, detection.IsHelmChartArchive(test.archiveFile, file)) + func() { + file, err := os.Open(testPath) + require.NoError(t, err) + defer file.Close() - _ = file.Close() + assert.Equal(t, test.isHelmChart, detection.IsHelmChartArchive(test.archiveFile, file)) + }() } }