No flags found
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
f4b0d9b
... +1 ...
a2cb4ba
Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.
e.g., #unittest #integration
#production #enterprise
#frontend #backend
3 | 3 | import cats.data.Ior |
|
4 | 4 | import cats.data.NonEmptyList |
|
5 | 5 | import cats.syntax.option._ |
|
6 | + | import scala.annotation.tailrec |
|
6 | 7 | ||
7 | 8 | case class DiffMatch[A]( difference: Option[Difference.Unordered], matches: List[( A, A )] ) |
|
8 | 9 |
32 | 33 | )( implicit D: Diff[A], H: Hint[A] ): ( List[A], List[A], List[( A, A )], List[Difference] ) = { |
|
33 | 34 | right.foldRight( ( left.toList, List.empty[A], List.empty[( A, A )], List.empty[Difference] ) ) { |
|
34 | 35 | case ( elem, ( remaining, unmatched, matches, mismatches ) ) => |
|
35 | - | def remainingAfter( matched: A ): List[A] = remaining.filterNot( matched == _ ) |
|
36 | + | def remainingAfter( matchedIx: Int ): List[A] = remaining.take( matchedIx ) ++ remaining.drop( matchedIx + 1 ) |
|
36 | 37 | ||
37 | 38 | def explainMismatch( a: A, d: Difference ): Difference = Difference.Tagged( s"at ${H.show( a )}", d ) |
|
38 | 39 | ||
39 | - | def search( prevMis: Option[( A, Difference )], excessMis: Boolean )( |
|
40 | - | cands: List[A] |
|
41 | - | ): Either[Option[( A, Difference )], A] = cands match { |
|
42 | - | case Nil => Left( prevMis.map { case ( a, d ) => ( a, explainMismatch( a, d ) ) } ) |
|
43 | - | case cand :: more if H( cand, elem ) => |
|
40 | + | @tailrec |
|
41 | + | def search( prevMis: Option[( A, Int, Difference )], excessMis: Boolean )( |
|
42 | + | cands: List[( A, Int )] |
|
43 | + | ): Either[Option[( Int, Difference )], ( A, Int )] = cands match { |
|
44 | + | case Nil => Left( prevMis.map { case ( a, ix, d ) => ( ix, explainMismatch( a, d ) ) } ) |
|
45 | + | case ( cand, ix ) :: more if H( cand, elem ) => |
|
44 | 46 | D( cand, elem ) match { |
|
45 | - | case None => Right( cand ) |
|
47 | + | case None => Right( ( cand, ix ) ) |
|
46 | 48 | case mis @ Some( _ ) => |
|
47 | 49 | val ( p, e ) = |
|
48 | 50 | if (excessMis || prevMis.nonEmpty || H.isDefault) ( none, true ) |
|
49 | - | else ( mis.map( cand -> _ ), false ) |
|
51 | + | else ( mis.map( ( cand, ix, _ ) ), false ) |
|
50 | 52 | search( p, e )( more ) |
|
51 | 53 | } |
|
52 | 54 | case _ :: more => search( prevMis, excessMis )( more ) |
|
53 | 55 | } |
|
54 | 56 | ||
55 | - | search( none, false )( remaining ) match { |
|
56 | - | case Right( newMatch ) => ( remainingAfter( newMatch ), unmatched, ( newMatch, elem ) :: matches, mismatches ) |
|
57 | - | case Left( None ) => ( remaining, elem :: unmatched, matches, mismatches ) |
|
58 | - | case Left( Some( ( mismatched, mismatch ) ) ) => |
|
59 | - | ( remainingAfter( mismatched ), unmatched, matches, mismatch :: mismatches ) |
|
57 | + | search( none, excessMis = false )( remaining.zipWithIndex ) match { |
|
58 | + | case Right( ( newMatch, ix ) ) => |
|
59 | + | ( remainingAfter( ix ), unmatched, ( newMatch, elem ) :: matches, mismatches ) |
|
60 | + | case Left( None ) => ( remaining, elem :: unmatched, matches, mismatches ) |
|
61 | + | case Left( Some( ( ix, mismatch ) ) ) => |
|
62 | + | ( remainingAfter( ix ), unmatched, matches, mismatch :: mismatches ) |
|
60 | 63 | } |
|
61 | 64 | ||
62 | 65 | } |
Files | Coverage |
---|---|
auto-diff-core/src/main/scala/fr/thomasdufour/autodiff | 76.28% |
auto-diff-generic/src/main/scala/fr/thomasdufour/autodiff/derived | 84.38% |
...f-enumeratum/src/main/scala/fr/thomasdufour/autodiff/extra/enumeratum.scala | 100.00% |
.../main/scala/fr/thomasdufour/autodiff/extra/scalatest/AutodiffMatchers.scala | 100.00% |
Project Totals (22 files) | 77.87% |
a2cb4ba
2bc72e6
f4b0d9b