Yesterday I bumped up the version of Freud from 0.9 to 1.0.
public static FreudAnalyser
doNotUseBigDecimalEquals(final AnalysedObjectIterator iterator)
{
return Freud.iterateOver(ClassFileMethod.class).
within(iterator).
assertThat(no(
hasMethodInvocation(BigDecimal.class, "equals", Object.class)));
}
The code should not throw any exceptions
public static FreudAnalyser
doNotThrowAnyExceptions(final AnalysedObjectIterator iterator)
{
return Freud.iterateOver(ClassFileMethod.class).within(iterator).
assertThat(no(containsInstructions(Opcode.ATHROW)));
}
public static FreudAnalyser
specificMethodsShouldNotHaveBranchLogic(
final AnalysedObjectIterator iterator)
{
return Freud.iterateOver(ClassFileMethod.class).within(iterator).
assertThat(no(methodName().matches("criticalPath")).
or(no(containsInstructions(Opcode.IFEQ,
Opcode.IFLT,
Opcode.IFLE,
Opcode.IFNE,
Opcode.IFGT,
Opcode.IFGE,
Opcode.IFNULL,
Opcode.IFNONNULL,
Opcode.IF_ICMPEQ,
Opcode.IF_ICMPGE,
Opcode.IF_ICMPGT,
Opcode.IF_ICMPLE,
Opcode.IF_ICMPLT,
Opcode.IF_ICMPNE,
Opcode.IF_ACMPEQ,
Opcode.IF_ACMPNE,
Opcode.TABLESWITCH,
Opcode.LOOKUPSWITCH,
Opcode.GOTO,
Opcode.GOTO_W,
Opcode.JSR,
Opcode.JSR_W))));
}
etc.
This joins the list of other currently supported content types in Freud:
Text
(For asserting things like – number of lines, line length, regex queries etc.)
Java Source
(Tests may include code block source size or existence of compile time annotation etc.).