Skip to content

Commit

Permalink
refactor: rename functions
Browse files Browse the repository at this point in the history
Signed-off-by: nikpivkin <[email protected]>
  • Loading branch information
nikpivkin committed Dec 24, 2024
1 parent a055b20 commit 71743c1
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/fanal/analyzer/language/python/poetry/poetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,8 @@ func (a poetryAnalyzer) mergePyProject(fsys fs.FS, dir string, app *types.Applic
return xerrors.Errorf("unable to parse %s: %w", path, err)
}

prodRootDeps := project.Tool.Poetry.Dependencies
directDeps := prodRootDeps.Union(getDevDeps(project))
prodDeps := getProdPackages(app, prodRootDeps)
directDeps := directDeps(project)
prodDeps := prodPackages(app, project.Tool.Poetry.Dependencies)

// Identify the direct/transitive/dev dependencies
for i, pkg := range app.Packages {
Expand All @@ -121,15 +120,15 @@ func (a poetryAnalyzer) mergePyProject(fsys fs.FS, dir string, app *types.Applic
return nil
}

func getDevDeps(project pyproject.PyProject) set.Set[string] {
deps := set.New[string]()
func directDeps(project pyproject.PyProject) set.Set[string] {
deps := project.Tool.Poetry.Dependencies.Clone()
for _, groupDeps := range project.Tool.Poetry.Groups {
deps.Append(groupDeps.Dependencies.Items()...)
}
return deps
}

func getProdPackages(app *types.Application, prodRootDeps set.Set[string]) set.Set[string] {
func prodPackages(app *types.Application, prodRootDeps set.Set[string]) set.Set[string] {
packages := lo.SliceToMap(app.Packages, func(pkg types.Package) (string, types.Package) {
return pkg.ID, pkg
})
Expand Down

0 comments on commit 71743c1

Please sign in to comment.