Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix length issues #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ func GetCopyright(content string) string {

if strings.EqualFold(copyrightLookup, tokens[0]) {
cr[matchLevel2] = line
if re.MatchString(tokens[1]) {
has_multiple_tokens := len(tokens) > 1

if has_multiple_tokens && re.MatchString(tokens[1]) {
cr[matchLevel1] = line
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/modules/gem/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ func isDuplicate(value string, spec Spec) bool {
return skip
}

// Builds Dependency Tree from Gemfile.lock
// Builds Dependency Tree from Gemfile.lock
func BuildLockDependencyTree(rows []string) {

var startIndex, specPosition int
Expand Down
32 changes: 17 additions & 15 deletions pkg/modules/yarn/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (m *yarn) SetRootModule(path string) error {
}

// GetRootModule return
//root package information ex. Name, Version
// root package information ex. Name, Version
func (m *yarn) GetRootModule(path string) (*models.Module, error) {
r := reader.New(filepath.Join(path, m.metadata.Manifest[0]))
pkResult, err := r.ReadJson()
Expand Down Expand Up @@ -207,15 +207,16 @@ func (m *yarn) buildDependencies(path string, deps []dependency) ([]models.Modul
if name == "optionalDependencies:" {
continue
}

version := strings.TrimSuffix(strings.TrimPrefix(strings.TrimSpace(ar[1]), "\""), "\"")
if extractVersion(version) == "*" {
continue
}
mod.Modules[name] = &models.Module{
Name: name,
Version: extractVersion(version),
CheckSum: &models.CheckSum{Content: []byte(fmt.Sprintf("%s-%s", name, version))},
if len(ar) > 1 {
version := strings.TrimSuffix(strings.TrimPrefix(strings.TrimSpace(ar[1]), "\""), "\"")
if extractVersion(version) == "*" {
continue
}
mod.Modules[name] = &models.Module{
Name: name,
Version: extractVersion(version),
CheckSum: &models.CheckSum{Content: []byte(fmt.Sprintf("%s-%s", name, version))},
}
}
}
}
Expand Down Expand Up @@ -390,12 +391,13 @@ func appendNestedDependencies(deps []dependency) []dependency {
if name == "optionalDependencies:" {
continue
}

version := strings.TrimSuffix(strings.TrimPrefix(strings.TrimSpace(ar[1]), "\""), "\"")
if extractVersion(version) == "*" {
continue
if len(ar) > 1 {
version := strings.TrimSuffix(strings.TrimPrefix(strings.TrimSpace(ar[1]), "\""), "\"")
if extractVersion(version) == "*" {
continue
}
allDeps = append(allDeps, dependency{Name: name, Version: extractVersion(version)})
}
allDeps = append(allDeps, dependency{Name: name, Version: extractVersion(version)})
}
}
}
Expand Down