I use the "fest-assert" library in unit tests, which produce "fluent assertions" that are easy to read from left to right.
If a developer hasn't written a test using TDD, they sometimes end up with a line of code like this:
assertThat(something);
This is wrong, because it has to do something more like this:
assertThat(something).is...
Where "is..." is one of many possible predicates, like "isEqualTo()" or "isTrue()" or "hasSize()", et cetera.
I'd like to see if it's possible to write a custom PMD rule that can detect that the return value from "assertThat()" is dropped on the table, as it's not followed by a chained method.
First, does anyone know if this is possible, and could provide an example of what this would look like?
Note that I'm using Sonar 3.7, which is using PMD 4.3. We're planning a Sona upgrade to either 4.1.2 or 4.2 very soon, but I don't know what version of PMD those versions use.
Please, do not double post. Thread closed. Continuing at http://sonarqube.15.x6.nabble.com/Write-a-custom-XPath-task-that-looks-for-a-method-that-is-NOT-followed-by-a-chained-method-call-td5024017.html