Examining reports on SonarCloud generated from Jenkins job kicked off by gerrit.
Sonar is now reporting “Refactor the code of the lambda to have only one invocation throwing an exception” for cases that were previously OK. Examining it further, the underlying condition is, “Only one method invocation is expected when testing runtime exceptions”.
First, this should only be an issue when testing unchecked exceptions; it should not matter when testing checked exceptions. Second, even when testing unchecked exceptions, if the other invocations cannot generate the particular Runtime exception being tested, then it should not matter if they are invoked.
It’s not like writing junit tests isn’t already tedious. Now, every method call in every lambda is going to have to be split out into its own statement. This needs to be tightened up so that it only reports if the assertion can pass due to more than one of the invocations throwing an exception.