squid:UnusedPrivateMethod reporting false positive for private constructor


(Stephen Palmer) #1

We use
*sonarQube 6.7.4
*sonarJava 5.5

squid:UnusedPrivateMethod is reporting that a private constructor is unused but it is being called from one or more public constructors e.g:

@JsonCreator
public ApplicationConfigurationJsonAdapter(@JacksonInject final JsonAdapterContext adapterContext) {
    this(adapterContext, null);
}

private ApplicationConfigurationJsonAdapter(final JsonAdapterContext adapterContext, final ApplicationConfiguration entity) {


}


(Adam Gabryś) #2

Hi,
I work with @stephenrpalmer. I cannot find a simple code construction which allows you to reproduce the bug.

I’ve found one interesting thing. this(...) is not clickable. It means Sonar parser doesn’t see link between this(...) and the private constructor.

Cheers


(Adam Gabryś) #3

The problem was caused by the incorrect classpath. We’ve fixed it and now the issue is closed.