Skip to content

Commit

Permalink
refactor: rename getProdDeps -> filterProdPackages
Browse files Browse the repository at this point in the history
Signed-off-by: nikpivkin <[email protected]>
  • Loading branch information
nikpivkin committed Dec 18, 2024
1 parent 7de61c8 commit 43adf6c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions pkg/fanal/analyzer/language/python/poetry/poetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,11 @@ func (a poetryAnalyzer) mergePyProject(fsys fs.FS, dir string, app *types.Applic
}
}

prodDeps := getProdDeps(project, app)

app.Packages = lo.Filter(app.Packages, func(pkg types.Package, _ int) bool {
_, ok := prodDeps[pkg.ID]
return ok
})

filterProdPackages(project, app)
return nil
}

func getProdDeps(project pyproject.PyProject, app *types.Application) map[string]struct{} {
func filterProdPackages(project pyproject.PyProject, app *types.Application) {
packages := lo.SliceToMap(app.Packages, func(pkg types.Package) (string, types.Package) {
return pkg.ID, pkg
})
Expand All @@ -144,7 +138,11 @@ func getProdDeps(project pyproject.PyProject, app *types.Application) map[string
}
walkPackageDeps(pkg.ID, packages, visited)
}
return visited

app.Packages = lo.Filter(app.Packages, func(pkg types.Package, _ int) bool {
_, ok := visited[pkg.ID]
return ok
})
}

func walkPackageDeps(pkgID string, packages map[string]types.Package, visited map[string]struct{}) {
Expand Down

0 comments on commit 43adf6c

Please sign in to comment.