Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif committed Oct 20, 2023
1 parent 73cd18a commit 295d07e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ jobs:
with:
fetch-depth: 0

- name: Override SuperLinter configs 💾
run: |
# Override markdownlint default config
[ ! -e .markdownlint.yaml ] && cat > .markdownlint.yaml <<EOF
###############
# Rules by id #
###############
MD013:
line_length: 1200 # Line length
EOF
shell: bash

- name: Lint Code Base 🕵🏻‍♀️
uses: github/super-linter/slim@v4
env:
Expand Down
9 changes: 1 addition & 8 deletions cmd/construct.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ func resolveDependenciesRecursively(outputList *[]OutputPackage, name string, ve
for i := 0; i < recursionLevel; i++ {
indentation += " "
}
if checkIfBasePackage(name) {
log.Debug(indentation, "Skipping package ", name, " as it is a base R package.")
return
}
if checkIfPackageOnOutputList(name, *outputList) {
log.Debug(indentation, "Package ", name, " is already present on the output list.")
return
}
for _, r := range repositoryList {
// Check if the package is present in the PACKAGES file for the repository.
for _, p := range packagesFiles[r].Packages {
Expand Down Expand Up @@ -116,6 +108,7 @@ func resolveDependenciesRecursively(outputList *[]OutputPackage, name string, ve
}
}
}
// TODO Should we fail in this case?
var versionConstraint string
if versionOperator != "" && versionValue != "" {
versionConstraint = " in version " + versionOperator + " " + versionValue
Expand Down
18 changes: 18 additions & 0 deletions cmd/construct_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,18 @@ func Test_constructOutputPackageList(t *testing.T) {
"",
"",
},
{
"Suggests",
"package16",
"",
"",
},
{
"Suggests",
"package1",
"",
"",
},
{
"Imports",
"package8",
Expand All @@ -328,6 +340,12 @@ func Test_constructOutputPackageList(t *testing.T) {
">=",
"2.3",
},
{
"Depends",
"non.existent.package",
"<",
"4.0.4",
},
{
"LinkingTo",
"package10",
Expand Down
9 changes: 8 additions & 1 deletion cmd/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion cmd/testdata/DESCRIPTION1
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion cmd/testdata/DESCRIPTION2
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 295d07e

Please sign in to comment.