Details
-
Type:
Improvement
-
Status: Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Rules
-
Labels:None
Description
S6073 considers wrapped method invocations like argument matchers. However, it does not recognize wrapped constructor calls the same way.
This produces FNs that may seem correct, but that are inconsistent with the rule implementation.
class Foo { public void bar(S6073Test.Container expected, String hello) { } } @ExtendWith(MockitoExtension.class) class S6073Test { @Test void myTest() { Foo foo = new Foo(); verify(foo).bar(expected(), "hello"); // ideally a FP verify(foo).bar(expected2(), "hello"); // currently a FN } Container expected() { //return Container.create(); return create(); } Container expected2() { return new Container(); } Container create() { return Container.create(); } static class Container { public static Container create() { return new Container(); } } }
Rather than updating the rule to recognize constructor calls as argument matchers, the checking of arguments should ignore wrapped methods invocations altogether when deciding if all arguments should be wrapped or not.
More precisely, it should ignore it when all return paths in the method (expected or expected2 here) lead to a method call.
Ideally, S6073 should not raise any issue on the code above.
Attachments
Issue Links
- links to