rewrite-testing-frameworks icon indicating copy to clipboard operation
rewrite-testing-frameworks copied to clipboard

AssertTrueInstanceofToAssertInstanceOf should add the required import statement

Open koppor opened this issue 2 years ago • 4 comments

I applied the rule, but get following compiler output:

 > Task :compileTestJava
/home/runner/work/jabref/jabref/src/test/java/org/jabref/logic/bst/BstVMVisitorTest.java:241: error: cannot find symbol
        assertInstanceOf(ParseTree.class, vm.getStack().pop());
        ^
  symbol:   method assertInstanceOf(Class<ParseTree>,Object)

My expection: The code generated by OpenRewrite compiles. It is OK, if the code does not meet checkstyle requirements (import order), but at least it should compile.

(Internal build: https://github.com/JabRef/jabref/actions/runs/6107579864)

koppor avatar Sep 07 '23 09:09 koppor

@AlekSimpson Is this something you can take on?

timtebeek avatar Sep 11 '23 13:09 timtebeek

What's curious is that we do already add the import; could there be missing type information here? If so we might want to add a precondition that there's no missing type information.

timtebeek avatar Sep 11 '23 13:09 timtebeek

Ya I can take this on

AlekSimpson avatar Sep 12 '23 14:09 AlekSimpson

It looks like the example here in https://github.com/JabRef/jabref/blob/22131c95a3af861f3d86daa448eb16ec1a14462e/src/test/java/org/jabref/logic/bst/BstVMVisitorTest.java#L242 has since been fixed manually in https://github.com/JabRef/jabref/commit/b3372fa894fbceb09fe28838a7db81748bef9e6f#diff-a4b5b4999b2f534c5380ab82041f79d16eee3e00da40d9333627c523c8835c76 I don't see any reason why that would have failed at the time. :/

timtebeek avatar Sep 14 '23 14:09 timtebeek