Reformat with scalafmt 3.0.0

This commit is contained in:
Scala Steward
2021-08-19 08:50:30 +02:00
parent 5a2a0295ef
commit e4fecefaea
127 changed files with 558 additions and 658 deletions

View File

@ -14,8 +14,7 @@ import docspell.query.ItemQuery.Expr.NotExpr
import docspell.query.ItemQuery.Expr.OrExpr
import docspell.query.ItemQuery._
/** Currently, fulltext in a query is only supported when in "root
* AND" position
/** Currently, fulltext in a query is only supported when in "root AND" position
*/
object FulltextExtract {
@ -45,15 +44,15 @@ object FulltextExtract {
def findFulltext(expr: Expr): Result =
lookForFulltext(expr)
/** Extracts the fulltext node from the given expr and returns it
* together with the expr without that node.
/** Extracts the fulltext node from the given expr and returns it together with the expr
* without that node.
*/
private def lookForFulltext(expr: Expr): Result =
expr match {
case Expr.Fulltext(ftq) =>
Result.SuccessNoExpr(ftq)
case Expr.AndExpr(inner) =>
inner.collect({ case Expr.Fulltext(fq) => fq }) match {
inner.collect { case Expr.Fulltext(fq) => fq } match {
case Nil =>
checkPosition(expr, 0)
case e :: Nil =>

View File

@ -10,12 +10,10 @@ import cats.data.{NonEmptyList => Nel}
import docspell.query.ItemQuery.Attr.{DateAttr, IntAttr, StringAttr}
/** A query evaluates to `true` or `false` given enough details about
* an item.
/** A query evaluates to `true` or `false` given enough details about an item.
*
* It may consist of (field,op,value) tuples that specify some checks
* against a specific field of an item using some operator or a
* combination thereof.
* It may consist of (field,op,value) tuples that specify some checks against a specific
* field of an item using some operator or a combination thereof.
*/
final case class ItemQuery(expr: ItemQuery.Expr, raw: Option[String]) {
def findFulltext: FulltextExtract.Result =

View File

@ -45,7 +45,7 @@ object ParseFailure {
def render: String = {
val opts = expected.mkString(", ")
val dots = if (exhaustive) "" else "…"
s"Expected: ${opts}${dots}"
s"Expected: $opts$dots"
}
}
@ -57,11 +57,11 @@ object ParseFailure {
)
private[query] def packMsg(msg: Nel[Message]): Nel[Message] = {
val expectMsg = combineExpected(msg.collect({ case em: ExpectMessage => em }))
val expectMsg = combineExpected(msg.collect { case em: ExpectMessage => em })
.sortBy(_.offset)
.headOption
val simpleMsg = msg.collect({ case sm: SimpleMessage => sm })
val simpleMsg = msg.collect { case sm: SimpleMessage => sm }
Nel.fromListUnsafe((simpleMsg ++ expectMsg).sortBy(_.offset))
}
@ -69,13 +69,13 @@ object ParseFailure {
private[query] def combineExpected(msg: List[ExpectMessage]): List[ExpectMessage] =
msg
.groupBy(_.offset)
.map({ case (offset, es) =>
.map { case (offset, es) =>
ExpectMessage(
offset,
es.flatMap(_.expected).distinct.sorted,
es.forall(_.exhaustive)
)
})
}
.toList
private[query] def expectationToMsg(e: Parser.Expectation): Message =
@ -89,7 +89,7 @@ object ParseFailure {
case InRange(offset, lower, upper) =>
if (lower == upper) ExpectMessage(offset, List(lower.toString), true)
else {
val expect = s"${lower}-${upper}"
val expect = s"$lower-$upper"
ExpectMessage(offset, List(expect), true)
}

View File

@ -13,8 +13,8 @@ import docspell.query.ItemQuery._
object ExprUtil {
/** Does some basic transformation, like unfolding nested and trees
* containing one value etc.
/** Does some basic transformation, like unfolding nested and trees containing one value
* etc.
*/
def reduce(expr: Expr): Expr =
expr match {