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

Nebula Lint does not handle certain `@Retention(RetentionPolicy.SOURCE)` annotations correctly #170

Open jsfzoloz opened 6 years ago

jsfzoloz commented 6 years ago

Summary:

Nebula Lint should not warn of an unused dependency for @Retention(RetentionPolicy.SOURCE) annotations .

Steps to reproduce:

Create a gradle project and add the gradle lint plugin. Add project lombok. Create a class and annotate it with a lombok annotation. Run gradle lint and observe the warning.

Extended Description:

Project Lombok is an annotation processor that will generate getters/setters for your code at compile time. Take a look at their @Data annotation source:

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.SOURCE)
public @interface Data {
}

Here is an example class using that

@Data
public class SomeDataStruct {
  private Integer id;
  private String name;
}

Nebula lint gives the following warning:

> Task :lintGradle FAILED

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 a service provider unused at compile time and can be moved to the runtime configuration

Workaround:

    gradleLint.ignore('unused-dependency') {
        compileOnly group: 'org.projectlombok', name: 'lombok', version:'1.16.20'
    }

Finally, thank you for making this plugin open source. I've found a lot of value in it.

dbolger commented 5 months ago

See my comment about this here: https://github.com/nebula-plugins/gradle-lint-plugin/issues/376#issuecomment-2096010123