A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pmd/pmd/issues/5523 below:

[java] UnnecessaryCast false-positive for integer operations in floating-point context · Issue #5523 · pmd/pmd · GitHub

Affects PMD Version:
7.10.0

Rule:
UnnecessaryCast

Description:
Division (or multiplication) of primitive integer and boxed integer in floating-point context is detected as unnecessary cast.

Code Sample demonstrating the issue:

Code:

class Scratch {
    public static void main(String[] args) {
        long x = 100;
        Integer y = 75;
        System.out.println(Math.ceil((double) x / y)); // <-- Unnecessary cast (double).
        System.out.println(Math.ceil(x / y));
    }
}

Output (the cast in question makes a difference and is therefore not unnecessary):

Expected outcome:

PMD reports a violation at line ..., but that's wrong. That's a false positive.

Running PMD through:
Maven


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4