nebula-plugins / gradle-lint-plugin

A pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts.
Apache License 2.0
771 stars 89 forks source link

Plugin not working on Gradle 7.2 #346

Closed boris-petrov closed 3 years ago

boris-petrov commented 3 years ago

I updated from Gradle 7.1.1 to Gradle 7.2 and I got the following running autoLintGradle:

        ...
Caused by: groovy.lang.MissingPropertyException: Exception evaluating property 'size' for com.google.common.collect.RegularImmutableList, Reason: groovy.lang.MissingPropertyException: No such property: size for class: java.lang.String
        at com.netflix.nebula.lint.rule.dependency.DependencyService.hasAResolutionAlternative(DependencyService.groovy:579)
        at com.netflix.nebula.lint.rule.dependency.DependencyService$hasAResolutionAlternative$1.callStatic(Unknown Source)
        at com.netflix.nebula.lint.rule.dependency.DependencyService$_resolvableConfigurations_closure16.doCall(DependencyService.groovy:191)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at com.netflix.nebula.lint.rule.dependency.DependencyService.resolvableConfigurations(DependencyService.groovy:191)
        at com.netflix.nebula.lint.rule.dependency.DependencyService.resolvableAndResolvedConfigurations(DependencyService.groovy:200)
        at com.netflix.nebula.lint.rule.dependency.DependencyService$resolvableAndResolvedConfigurations$0.call(Unknown Source)
        at com.netflix.nebula.lint.rule.dependency.AbstractDuplicateDependencyClassRule.beforeApplyTo(AbstractDuplicateDependencyClassRule.groovy:36)
        at com.netflix.nebula.lint.rule.GradleLintRule.applyTo(GradleLintRule.groovy:198)
        at com.netflix.nebula.lint.org.codenarc.rule.Rule$applyTo$0.call(Unknown Source)
        at com.netflix.nebula.lint.org.codenarc.rule.Rule$applyTo$0.call(Unknown Source)
        at com.netflix.nebula.lint.org.codenarc.analyzer.AbstractSourceAnalyzer$_collectViolations_closure3.doCall(AbstractSourceAnalyzer.groovy:46)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at com.netflix.nebula.lint.org.codenarc.analyzer.AbstractSourceAnalyzer.measureRuleProcessingTime(AbstractSourceAnalyzer.groovy:58)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at com.netflix.nebula.lint.org.codenarc.analyzer.AbstractSourceAnalyzer.collectViolations(AbstractSourceAnalyzer.groovy:44)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at com.netflix.nebula.lint.plugin.LintService$ReportableAnalyzer.analyze(LintService.groovy:58)
        at com.netflix.nebula.lint.plugin.LintService$ReportableAnalyzer$analyze.call(Unknown Source)
        at com.netflix.nebula.lint.plugin.LintService$_lint_closure5.doCall(LintService.groovy:129)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at com.netflix.nebula.lint.plugin.LintService.lint(LintService.groovy:118)
        at com.netflix.nebula.lint.plugin.LintService$lint.call(Unknown Source)
        at com.netflix.nebula.lint.plugin.LintGradleTask.lint(LintGradleTask.groovy:47)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
        ...

Not sure if you can understand what's the problem... it blows up on this line. If you need a reproduction, please tell me and I'll try to provide one.

DanielThomas commented 3 years ago

That's odd, that method and it's return type hasn't changed in two years. To avoid ambiguity we probably just need to use size() there instead of the property accessor. We're working on 7.2 now so we'll look at this in the next week or so.

boris-petrov commented 3 years ago

@DanielThomas - I just realized that Gradle 7.2 updated Groovy from 3.0.7 to 3.0.8. Most likely that's the reason for the failure.

DanielThomas commented 3 years ago

@boris-petrov good catch, very likely related, thanks. Nothing stands out on a quick glance, but we can probably add @CompileStatic to this class to catch whatever is going on at build time.

http://groovy-lang.org/changelogs/changelog-3.0.8.html

rpalcolea commented 3 years ago

This should be fixed now in 17.1.1

plugins {
    id "java-library"
    id "nebula.lint" version "17.1.1"
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'com.google.guava:guava:19.0'
}

gradleLint {
    rules  = ['all-dependency']
}

results in

Caching disabled for task ':lintGradle' because:
  Build cache is disabled
Task ':lintGradle' is not up-to-date because:
  Task has not declared any outputs despite executing actions.

This project contains lint violations. A complete listing of the violations follows.
Because none were serious, the build's overall status was unaffected.

warning   unused-dependency                  this dependency is unused and can be removed
build.gradle:11
implementation 'com.google.guava:guava:19.0'

✖ 1 problem (0 errors, 1 warning)

To apply fixes automatically, run fixGradleLint, review, and commit the changes.

:lintGradle (Thread[Execution worker for ':',5,main]) completed. Took 0.651 secs.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':lintGradle'.
> This build contains 1 lint violation
boris-petrov commented 3 years ago

It indeed is! Thank you!