Open inguemark-spec opened 2 years ago
The rule "The variable value is not assigned" (JAVA) can report false positives.
For example :
private void test() { Object value = getValue (); if (value instanceof String stringValue) { Logger.getLogger("this is a String : " + stringValue); } if (value instanceof Integer intValue) { Logger.getLogger("this is a Integer : " + intValue); } }
In this case, the variable is indeed used in the condition, and is then cast.
Note: This is a Java 17 language feature https://docs.oracle.com/en/java/javase/17/language/pattern-matching-instanceof-operator.html
The rule "The variable value is not assigned" (JAVA) can report false positives.
For example :
In this case, the variable is indeed used in the condition, and is then cast.