Skip to content

Commit

Permalink
fix linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nikpivkin committed May 3, 2024
1 parent c4cdbca commit c840605
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions pkg/iac/scanners/helm/parser/parser_tar.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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 {
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions pkg/iac/scanners/helm/test/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}()
}
}

Expand Down

0 comments on commit c840605

Please sign in to comment.