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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -