diff --git a/internal/bundle/bundle_manager.go b/internal/bundle/bundle_manager.go index 755cb885..5e5618f0 100644 --- a/internal/bundle/bundle_manager.go +++ b/internal/bundle/bundle_manager.go @@ -18,10 +18,11 @@ package bundle import ( "context" - deepcode2 "github.com/snyk/code-client-go/internal/deepcode" "os" "path/filepath" + deepcode2 "github.com/snyk/code-client-go/internal/deepcode" + "github.com/puzpuzpuz/xsync" "github.com/rs/zerolog" @@ -116,9 +117,10 @@ func (b *bundleManager) Create(ctx context.Context, } relativePath = util.EncodePath(relativePath) - bundleFile := deepcode2.BundleFileFrom(absoluteFilePath, fileContent) + bundleFile := deepcode2.BundleFileFrom(fileContent) bundleFiles[relativePath] = bundleFile fileHashes[relativePath] = bundleFile.Hash + b.logger.Trace().Str("method", "BundleFileFrom").Str("hash", bundleFile.Hash).Str("filePath", absoluteFilePath).Msg("") if changedFiles[absoluteFilePath] { limitToFiles = append(limitToFiles, relativePath) diff --git a/internal/deepcode/helpers.go b/internal/deepcode/helpers.go index 0901bf1f..820a1e85 100644 --- a/internal/deepcode/helpers.go +++ b/internal/deepcode/helpers.go @@ -16,8 +16,6 @@ package deepcode import ( - "github.com/rs/zerolog/log" - "github.com/snyk/code-client-go/internal/util" ) @@ -26,11 +24,10 @@ type BundleFile struct { Content string `json:"content"` } -func BundleFileFrom(filePath string, content []byte) BundleFile { +func BundleFileFrom(content []byte) BundleFile { file := BundleFile{ Hash: util.Hash(content), Content: string(content), } - log.Trace().Str("method", "BundleFileFrom").Str("hash", file.Hash).Str("filePath", filePath).Msg("") return file } diff --git a/scan_test.go b/scan_test.go index c387b461..8b6e530d 100644 --- a/scan_test.go +++ b/scan_test.go @@ -17,13 +17,14 @@ package codeclient_test import ( "context" + "os" + "path/filepath" + "testing" + "github.com/snyk/code-client-go/internal/bundle" bundleMocks "github.com/snyk/code-client-go/internal/bundle/mocks" "github.com/snyk/code-client-go/internal/deepcode" deepcodeMocks "github.com/snyk/code-client-go/internal/deepcode/mocks" - "os" - "path/filepath" - "testing" "github.com/golang/mock/gomock" "github.com/rs/zerolog" @@ -40,8 +41,8 @@ func Test_UploadAndAnalyze(t *testing.T) { baseDir, firstDocPath, secondDocPath, firstDocContent, secondDocContent := setupDocs(t) docs := sliceToChannel([]string{firstDocPath, secondDocPath}) files := map[string]deepcode.BundleFile{ - firstDocPath: deepcode.BundleFileFrom(firstDocPath, firstDocContent), - firstDocPath: deepcode.BundleFileFrom(secondDocPath, secondDocContent), + firstDocPath: deepcode.BundleFileFrom(firstDocContent), + firstDocPath: deepcode.BundleFileFrom(secondDocContent), } logger := zerolog.Nop()