dependency injection - Java method with @Inject annotation: False-positive for the rule "Unused "private" methods should be removed"? -
we using java 8 , dependency injection (guice). have false-positive sonar issue, unused method, although method invoked via reflection guice injector, due inject annotation.
affected code:
@inject private void settransactionalcommandstack(transactionalcommandstack transactionalcommandstack) { ... }
sq reports violation of rule squid:unusedprivatemethod
unused "private" methods should removed
at place , says
private method 'settransactionalcommandstack' never used
.
the eclipse environment has check unused methods detects correctly , puts warning if have no @inject annotation method. same expect in sonarqube.
i tested both annotation javax.inject.inject , com.google.inject.inject. in both cases sonarqube reports method unused.
sq version: 5.3
java plugin version: 3.14
this issue has been fixed in version 4.0
of java analyzer, compatible sq lts 5.6
. see corresponding jira ticket sonarjava-1179
Comments
Post a Comment