Wrong Deprecation warning bug for java:S1874

I discovered a bug in the sonarlint Plugin for intellij idea

if you use a method from another class in a project that contains another method with different arguments that is deprecated, both methods are marked with the same name as needing improvement even if the actual method is not deprecated

steps to reproduce:

create a class with two methods that have the same name but take different parameters, mark one method as deprecated and call the non-deprecated method in another class

potential workaround: Differentiation of the parameters

picture: https://i.imgur.com/bLltyC1.png
picture 2:

Hello @NonSwag ,

Unfortunately, we can not reproduce the issue on our side with a similar situation:

public class A {
  void foo(Object o) { }

  @Deprecated
  void foo(String b) { }

  static class B {
    void foo() {
      A a = new A();

      a.foo(0);

      a.foo(""); // True Positive java:S1874
    }
  }
}

From your use-case, would it be possible to share the method signature of property.getOwner() ?
We feel it might be the cause of the issue, but it would really help if you could provide an actual reproducer and not screenshot, as it would definitely ease our investigation. :+1:

Cheers,
Michael

We’re seeing the same issue, but it’s on constructing a java.util.Date with a long, where the String constructor is deprecated.

Hi @EvanKnowles,
I can reproduce this bug when the java analyzer does not resolve completely the semantic information. In your case when entityScoringInfoRequest type description is unknown. The following ticket should fix this false positive: SONARJAVA-4070
But why the java analyzer does not resolve the semantic information? This is another problem that you probably have. Is there the following message in the analysis log: WARN: Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
So if SONARJAVA-4070 does not fix all your problems, pealse create a new topic in this community forum.