Skip to content

New Rule: Detect when all{} should be used #14

Description

@inktomi

A new rule to suggest usages of all would be helpful.

Perhaps, given code like this, we'd get a warning to use all instead:

assertThat(complexType.skyIsBlue).isTrue()
assertThat(complexType.raining).isFalse()
assertThat(complexType.cake.yummy).isTrue()

I think this would be better written with all:

assertThat(complexType).all {
    prop(ComplexType::skyIsBlue).isTrue()
    prop(ComplexType::raining).isFalse()
    prop(ComplexType::cake).isInstanceOf(Cake::class).prop(Cake::yummy).isTrue()
}

In this case, with all we'd get the evaluations for raining and cake even if the sky isn't blue.

Maybe the rule could check for 3+ assertions on the same variable and then suggest using all instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions