S1258 Should not raise an issue for maven plugin code

java

(Slawomir Jaranowski) #1

In maven plugins development we use plexus component like:

import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;

@Component( role = MyComponent.class, hint = "hint-value" )
public class MyComponentImplementation implements MyComponent {

    @Requirement
    private InjectedComponent;
}

And next example, Maven mojo code:

import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

@Mojo(name = "myMojo")
public class MyMojo extends AbstractMojo {
   
    @Parameter(property = "project", readonly = true, required = true)
    private MavenProject project;

    @Component
    private ProjectDependenciesResolver resolver;

    @Parameter(property = "my.skip", defaultValue = "false")
    private boolean skip;
}

I think that all class with annotation org.codehaus.plexus.component.annotations.Component and org.apache.maven.plugins.annotations.Mojo should be skipped because in this case we don’t define specific constructor for class which is managed by maven environment.