jborgers / PMD-jPinpoint-rules

PMD rule set for responsible Java and Kotlin coding: performance, sustainability, multi-threading, data mixup and more.
Apache License 2.0
43 stars 10 forks source link

Fix Request for UnconditionalOperationOnLogArgument: Spurious violations on chained operations #415

Closed jborgers closed 1 week ago

jborgers commented 1 week ago
@Slf4j
public final class DataUtil {

 public static void addTestData(URI uri, List<TransactionDocument> documents) {
        String data = documents.stream()
            .map(document -> document.toString() + "\n")
            .collect(Collectors.joining());
        log.info(WebClient.builder().build().post() // <--- 4x violation, should be 1
            .uri(uri.resolve("/_bulk")) // <-- violation, not needed
            .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)
            .body(BodyInserters.fromValue(data)) // <-- violation, not needed
            .exchange()
            .flatMap(clientResponse -> clientResponse.bodyToMono(String.class)) // <-- violation, not needed
            .block());
    }
}
jborgers commented 1 week ago

1 violation should cover them all