S1874 FP "@Deprecated" code should not be used java:S1874, in ObjectNode

False positive with rule java:S1874 “@ Deprecated” code should not be used

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.15.2</version>
</dependency>

In class com.fasterxml.jackson.databind.node.ObjectNode the put method with JsonNode as value is deprecated:

public JsonNode put(String propertyName, JsonNode value)

But all other put methods are not, like this one with a String value:

public ObjectNode put(String fieldName, String v)

Example:

ObjectNode node = new ObjectMapper().createObjectNode();
node.put("field", "value");

SonarQube Enterprise generates an issue ‘Remove this use of “put”; it is deprecated.’ but the put method with a String value is not deprecated.


Eduardo Ito.

Hey there.

What version of SonarQube are you using? You should be able to find this in the footer of your SonarQube instance.