[java:S1149] FP when using method from Stack, that doesn't exists in Deque or ArrayDeque

Qube: Community 9.9

The Java rule S1149 wants me to use Deque instead of Stack, because Stack is synchronized. Fine!

If the code invokes a method from Stack, that doesn’t exist in Deque and not even in ArrayDeque, the rule should not hit.

public void foo(Stack<String> stack) { // FP
    stack.get(1); // The get(int) method does not exist in Deque, nor in ArrayDeque.

Hey Marvin, thanks for the report.

I feel it makes sense to exclude issue reporting in such cases, as it would require the whole logic of the impacted method to be changed. I created a ticket to improve the rule.

1 Like