gradle-lint-plugin
gradle-lint-plugin copied to clipboard
unused-dependency does not seem to work for modules
Hello.
I have a very basic setup, a multimodule demo project, with two modules and one build.gradle as follows:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.netflix.nebula:gradle-lint-plugin:latest.release'
}
}
allprojects {
apply plugin: 'java'
apply plugin: 'nebula.lint'
repositories {
mavenCentral()
jcenter()
}
gradleLint {
rules = ['dependency-parentheses', 'unused-dependency']
}
}
dependencies {
compile(group: 'com.google.guava', name: 'guava', version: '26.0-jre')
}
project(':config') {
dependencies {
compile group: 'com.itextpdf', name: 'itextpdf', version: '5.5.13'
compile group: 'org.apache.openjpa', name: 'openjpa', version: '3.0.0'
}
}
project(':api') {
dependencies {
compile('org.codehaus.groovy:groovy-all:2.3.11')
testCompile group: 'junit', name: 'junit', version: '4.12'
}
}
For each module, I only have a dummy java source file with a main method that prints something. When I generate the report, I get this:
:generateGradleLintReport
Generated a report containing information about 2 lint violations in this project
:config:generateGradleLintReport
Generated a report containing information about 0 lint violations in this project
:api:generateGradleLintReport
Generated a report containing information about 0 lint violations in this project
BUILD SUCCESSFUL
Total time: 3.08 secs
This project contains lint violations. A complete listing of the violations follows.
Because none were serious, the build's overall status was unaffected.
warning dependency-parentheses parentheses are unnecessary for dependencies
build.gradle:23
compile(group: 'com.google.guava', name: 'guava', version: '26.0-jre')
warning unused-dependency this dependency is unused and can be removed
build.gradle:23
compile(group: 'com.google.guava', name: 'guava', version: '26.0-jre')
warning dependency-parentheses parentheses are unnecessary for dependencies
build.gradle:35
compile('org.codehaus.groovy:groovy-all:2.3.11')
✖ 3 problems (0 errors, 3 warnings)
The rule "dependency-parentheses" is applied both to the root project and to his modules, but for some reason the rule "unused-dependency" is only applied to the root project (it seems). Also, although there is a "dependency-parentheses" violation being reported for the "api" module, the report is misleading:
:api:generateGradleLintReport
Generated a report containing information about 0 lint violations in this project
Am I doing something wrong? Thank you for your help.
Hi @pedrovaldevino the lint plugin operates at the level of files. Your file with violations is in the root project so it is being reported as its violations. Regarding to missing unused dependencies, I don't know. We are not currently using that rule and we don't have spare time to investigate details right now. I would suggest not to use the rule right now. We plan to refresh it and start using it again in the following 3 months. Hopefully, you can reintroduce it later. Sorry about that.
I've the same problem, multi module project and don't works.
same here
@chali - request for status update.
Do you have any plans now to update the rule?
Btw, do you use multimodule gradle projects at Netflix? What was the reason not to use this rule for a while?
Hi @bagza unfortunately, there was no progress and we don't have any plans to work on it for now. We use a lot of multimodule projects. The main reason why we abandoned this rule is the performance and reliability of results. We have seen quite a big amount of false positive results. The performance is problematic because the rule has to scan the whole classpath. Right now linting is happening in each build as part of regular development workflow.