Skip to content

Commit

Permalink
Merge 59edffe into f4504c0
Browse files Browse the repository at this point in the history
  • Loading branch information
rpalcolea committed Oct 24, 2019
2 parents f4504c0 + 59edffe commit 14d3ccc
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class DependencyService {
if(isResolvable(childConfig)) {
declared.addAll childConfig.resolvedConfiguration.firstLevelModuleDependencies.collect { it.module.id }
} else {
declared.addAll childConfig.dependencies.collect { new DefaultModuleVersionIdentifier(it.group, it.name, it.version) }
declared.addAll getResolvableConfigurationOrParent(childConfig.name).resolvedConfiguration.firstLevelModuleDependencies.collect { it.module.id }
}
}
return declared
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class UnusedDependencyRuleSpec extends TestKitSpecification {
[guava, springfox] | ['warning unused-dependency this dependency is unused and can be removed']
}


@Unroll
def 'unused api dependencies are marked for deletion'() {
when:
Expand Down Expand Up @@ -539,4 +540,47 @@ class UnusedDependencyRuleSpec extends TestKitSpecification {
println(results.output)
results.output.readLines().count { it.contains('unused-dependency') } == 1
}
@Issue("258")
def 'does not fail with dependency constraints'() {
setup:
def expectedWarnings = [
'warning unused-dependency one or more classes in com.google.guava:guava:18.0 are required by your code directly (no auto-fix available)',
'warning unused-dependency this dependency is unused and can be removed'
]
when:
buildFile.text = """\
plugins {
id 'nebula.lint'
id 'java'
}
gradleLint.rules = ['unused-dependency']
repositories { mavenCentral() }
dependencies {
implementation 'com.google.guava:guava:18.0'
implementation 'org.apache.httpcomponents:httpclient'
constraints {
implementation('org.apache.httpcomponents:httpclient:4.5.3') {
because 'previous versions have a bug impacting this application'
}
implementation('commons-codec:commons-codec:1.11') {
because 'version 1.9 pulled from httpclient has bugs affecting this application'
}
}
}""".stripMargin()
createJavaSourceFile(main)
def result = runTasksSuccessfully('compileJava', 'autoLintGradle')
then:
expectedWarnings.each {
assert result.output.contains(it)
}
}
}

0 comments on commit 14d3ccc

Please sign in to comment.