From 780be44d72d39c20bb2e9d6d509f883d3f6e662a Mon Sep 17 00:00:00 2001 From: Martin Chalupa Date: Thu, 8 Apr 2021 11:15:58 -0700 Subject: [PATCH] Best effort detection of project dependencies with complex parameters how to declare project name, we list dependency but project name is skipped --- .../com/netflix/nebula/lint/rule/GradleLintRule.groovy | 2 ++ .../netflix/nebula/lint/rule/GradleLintRuleSpec.groovy | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/com/netflix/nebula/lint/rule/GradleLintRule.groovy b/src/main/groovy/com/netflix/nebula/lint/rule/GradleLintRule.groovy index 1d238bae..6b909593 100644 --- a/src/main/groovy/com/netflix/nebula/lint/rule/GradleLintRule.groovy +++ b/src/main/groovy/com/netflix/nebula/lint/rule/GradleLintRule.groovy @@ -458,6 +458,8 @@ abstract class GradleLintRule extends GroovyAstVisitor implements Rule { def path = entries.get("path") if (path != null) visitAnySubmoduleDependency(call, methodName, path) + } else { + visitAnySubmoduleDependency(call, methodName, null) } } diff --git a/src/test/groovy/com/netflix/nebula/lint/rule/GradleLintRuleSpec.groovy b/src/test/groovy/com/netflix/nebula/lint/rule/GradleLintRuleSpec.groovy index 8c9cf777..cc8388cb 100644 --- a/src/test/groovy/com/netflix/nebula/lint/rule/GradleLintRuleSpec.groovy +++ b/src/test/groovy/com/netflix/nebula/lint/rule/GradleLintRuleSpec.groovy @@ -280,13 +280,18 @@ class GradleLintRuleSpec extends AbstractRuleSpec { given: def library = addSubproject('library') def library2 = addSubproject('library2') + def library3 = addSubproject('library3') library.configurations.create('compile') project.subprojects.add(library) project.subprojects.add(library2) + project.subprojects.add(library3) project.buildFile << """ + def baseName = ":library" + dependencies { compile project(":library") compile project(path: ":library2") + compile project("\${baseName}3") } """ @@ -294,9 +299,10 @@ class GradleLintRuleSpec extends AbstractRuleSpec { def foundDependencies = new DependencyVisitingRule().run().submoduleDependencies then: - foundDependencies.size() == 2 + foundDependencies.size() == 3 foundDependencies[0] == ':library' foundDependencies[1] == ':library2' + foundDependencies[2] == null } def 'visit adding file collections and other configurations into a configuration'() {