5

IntelliJ IDEA (2017.2) emits the following warning on Spock interactions that combine cardinality with a return value.

'multiply' in 'org.codehaus.groovy.runtime.DefaultGroovyMethods' cannot be applied to...

...followed by the return type of the interaction.

Neither stubs nor mocks alone emit a warning, only the combination of the two.

  • 1 * mockDAO.deleteData() is OK.

  • mockDAO.readData() >> myData is OK.

  • 1 * mockDAO.readData() >> myData is a warning.

Is there any setting or syntax to make IntelliJ understand the mock/stub combination?

jaco0646
  • 15,303
  • 7
  • 59
  • 83
  • 4
    It's a lack of special support for spock in intellij, see also https://youtrack.jetbrains.com/issue/IDEA-87240 and https://youtrack.jetbrains.com/issue/IDEA-171311 – Leonard Brünings Aug 15 '17 at 00:50
  • Thanks, the second link is spot on. Out of curiosity, any idea how the first two bullet points are validated without Spock support? It seems multiplication and right shift can be applied to any types, just not together. – jaco0646 Aug 15 '17 at 01:20
  • my guess is that the operator precedence and type inference screws something up https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html http://groovy-lang.org/operators.html#_operator_precedence – Leonard Brünings Aug 15 '17 at 14:38
  • would be great if at least `@SuppressWarnings` could be applied – MemLeak Feb 14 '19 at 15:43
  • 1
    @MemLeak, it can be suppressed with `@SuppressWarnings("GroovyAssignabilityCheck")` but that blocks other helpful type checks as well. – jaco0646 May 10 '19 at 13:14

1 Answers1

0

IntelliJ fixed this issue in version 2019.1: specifically, issue 205861. Regarding the issues mentioned in the comment from @Leonard Brünings, issue 171311 is marked as a duplicate of this; and several additional Spock issues were fixed in the same release, including 87240.

jaco0646
  • 15,303
  • 7
  • 59
  • 83