diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 3f140b8..002def5 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -28,6 +28,18 @@ jobs: with: fetch-depth: 0 + - name: Override SuperLinter configs 💾 + run: | + # Override markdownlint default config + [ ! -e .markdownlint.yaml ] && cat > .markdownlint.yaml <=", "2.3", }, + { + "Depends", + "non.existent.package", + "<", + "4.0.4", + }, { "LinkingTo", "package10", diff --git a/cmd/parse.go b/cmd/parse.go index 8e21740..c76260e 100644 --- a/cmd/parse.go +++ b/cmd/parse.go @@ -130,6 +130,10 @@ func cleanDescriptionOrPackagesEntry(description string) string { return outputContent } +func splitPackageName(r rune) bool { + return r == ' ' || r == '(' +} + // Processes a map containing a YAML-like object representing dependencies of a package. // Returns a list of Dependency structures corresponding to dependency name, and version constraints. func processDependencyFields(packageMap map[string]string, @@ -140,7 +144,10 @@ func processDependencyFields(packageMap map[string]string, if _, ok := packageMap[field]; ok { dependencyList := strings.Split(packageMap[field], ", ") for _, dependency := range dependencyList { - dependencyName := strings.Split(dependency, " ")[0] + // There might be a space or '(' right after the package name, + // so both space and '(' are treated as a delimiter to get the + // package name from the first field. + dependencyName := strings.FieldsFunc(dependency, splitPackageName)[0] versionConstraintOperator := "" versionConstraintValue := "" // Check if package is required in some particular version. diff --git a/cmd/testdata/DESCRIPTION1 b/cmd/testdata/DESCRIPTION1 index 5acf28c..f3fb8a7 100644 --- a/cmd/testdata/DESCRIPTION1 +++ b/cmd/testdata/DESCRIPTION1 @@ -7,7 +7,7 @@ Description: This is a multiline string representing package description. License: Apache License 2.0 Depends: - R (>= 4.0), + R(>= 4.0), shiny (>= 1.7.0) Imports: checkmate, diff --git a/cmd/testdata/DESCRIPTION2 b/cmd/testdata/DESCRIPTION2 index 299ee23..39d8dac 100644 --- a/cmd/testdata/DESCRIPTION2 +++ b/cmd/testdata/DESCRIPTION2 @@ -10,7 +10,7 @@ Depends: Imports: dplyr, forcats (>= 1.0.0), formatters (>= 0.5.3), - ggplot2 (>= 3.4.0), + ggplot2(>= 3.4.0), stats, survival (>= 3.2-13),