Suggestion: Improve double-comparisons #4

Open
opened 2021-06-28 14:57:43 +02:00 by myplacedk · 1 comment
myplacedk commented 2021-06-28 14:57:43 +02:00 (Migrated from github.com)

I fixed a bunch of lines like this:

assertThat(Math.abs(actual - expected) < tolerance).isTrue();

Cajon suggests changing it to:

assertThat(Math.abs(actual - expected)).isLessThan(tolerance);

Maybe Cajon should suggest changing either to:

assertThat(actual).isCloseTo(expected, within(tolerance));

I might make a PR for this later.

I fixed a bunch of lines like this: assertThat(Math.abs(actual - expected) < tolerance).isTrue(); Cajon suggests changing it to: assertThat(Math.abs(actual - expected)).isLessThan(tolerance); Maybe Cajon should suggest changing either to: assertThat(actual).isCloseTo(expected, within(tolerance)); I might make a PR for this later.
chrisly42 commented 2021-06-29 16:59:56 +02:00 (Migrated from github.com)

Hi there,

yes, this seems a legit transformation (it's strange what people come up with, I thought calling compare() was already weird enough). It's not quite a straight forward transformation, though, so if you want me to do it myself, I will do so. Let me know.

Hi there, yes, this seems a legit transformation (it's strange what people come up with, I thought calling compare() was already weird enough). It's not quite a straight forward transformation, though, so if you want me to do it myself, I will do so. Let me know.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: chrisly42/cajon-plugin#4
No description provided.