mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 02:18:26 +00:00
Update scalafmt settings
This commit is contained in:
@ -18,7 +18,7 @@ sealed trait AccountSource { self: Product =>
|
||||
|
||||
object AccountSource {
|
||||
|
||||
case object Local extends AccountSource
|
||||
case object Local extends AccountSource
|
||||
case object OpenId extends AccountSource
|
||||
|
||||
val all: NonEmptyList[AccountSource] =
|
||||
|
@ -62,10 +62,10 @@ object Binary {
|
||||
private val utf8Bom: Chunk[Byte] = Chunk(0xef.toByte, 0xbb.toByte, 0xbf.toByte)
|
||||
|
||||
def decode[F[_]](charset: Charset): Pipe[F, Byte, String] = {
|
||||
val decoder = charset.newDecoder
|
||||
val decoder = charset.newDecoder
|
||||
val maxCharsPerByte = math.ceil(decoder.maxCharsPerByte().toDouble).toInt
|
||||
val avgBytesPerChar = math.ceil(1.0 / decoder.averageCharsPerByte().toDouble).toInt
|
||||
val charBufferSize = 128
|
||||
val charBufferSize = 128
|
||||
|
||||
_.repeatPull[String] {
|
||||
_.unconsN(charBufferSize * avgBytesPerChar, allowFewer = true).flatMap {
|
||||
@ -79,9 +79,9 @@ object Binary {
|
||||
case Some((chunk, stream)) =>
|
||||
if (chunk.nonEmpty) {
|
||||
val chunkWithoutBom = skipByteOrderMark(chunk)
|
||||
val bytes = chunkWithoutBom.toArray
|
||||
val byteBuffer = ByteBuffer.wrap(bytes)
|
||||
val charBuffer = CharBuffer.allocate(bytes.length * maxCharsPerByte)
|
||||
val bytes = chunkWithoutBom.toArray
|
||||
val byteBuffer = ByteBuffer.wrap(bytes)
|
||||
val charBuffer = CharBuffer.allocate(bytes.length * maxCharsPerByte)
|
||||
decoder.decode(byteBuffer, charBuffer, false)
|
||||
val nextStream = stream.consChunk(Chunk.byteBuffer(byteBuffer.slice()))
|
||||
Pull.output1(charBuffer.flip().toString).as(Some(nextStream))
|
||||
|
@ -23,8 +23,7 @@ object CollectiveState {
|
||||
/** A collective that has been explicitely closed. */
|
||||
case object Closed extends CollectiveState
|
||||
|
||||
/** A collective blocked by a super user, usually some emergency action.
|
||||
*/
|
||||
/** A collective blocked by a super user, usually some emergency action. */
|
||||
case object Blocked extends CollectiveState
|
||||
|
||||
def fromString(s: String): Either[String, CollectiveState] =
|
||||
|
@ -16,10 +16,10 @@ sealed trait ContactKind { self: Product =>
|
||||
object ContactKind {
|
||||
val all = List()
|
||||
|
||||
case object Phone extends ContactKind
|
||||
case object Mobile extends ContactKind
|
||||
case object Fax extends ContactKind
|
||||
case object Email extends ContactKind
|
||||
case object Phone extends ContactKind
|
||||
case object Mobile extends ContactKind
|
||||
case object Fax extends ContactKind
|
||||
case object Email extends ContactKind
|
||||
case object Website extends ContactKind
|
||||
|
||||
def fromString(s: String): Either[String, ContactKind] =
|
||||
|
@ -93,11 +93,11 @@ object CustomFieldType {
|
||||
v.setScale(2, BigDecimal.RoundingMode.HALF_EVEN)
|
||||
}
|
||||
|
||||
def text: CustomFieldType = Text
|
||||
def text: CustomFieldType = Text
|
||||
def numeric: CustomFieldType = Numeric
|
||||
def date: CustomFieldType = Date
|
||||
def bool: CustomFieldType = Bool
|
||||
def money: CustomFieldType = Money
|
||||
def date: CustomFieldType = Date
|
||||
def bool: CustomFieldType = Bool
|
||||
def money: CustomFieldType = Money
|
||||
|
||||
val all: NonEmptyList[CustomFieldType] =
|
||||
NonEmptyList.of(Text, Numeric, Date, Bool, Money)
|
||||
|
@ -8,9 +8,9 @@ package docspell.common
|
||||
|
||||
object DocspellSystem {
|
||||
|
||||
val user = Ident.unsafe("docspell-system")
|
||||
val taskGroup = user
|
||||
val migrationTaskTracker = Ident.unsafe("full-text-index-tracker")
|
||||
val allPreviewTaskTracker = Ident.unsafe("generate-all-previews")
|
||||
val user = Ident.unsafe("docspell-system")
|
||||
val taskGroup = user
|
||||
val migrationTaskTracker = Ident.unsafe("full-text-index-tracker")
|
||||
val allPreviewTaskTracker = Ident.unsafe("generate-all-previews")
|
||||
val allPageCountTaskTracker = Ident.unsafe("all-page-count-tracker")
|
||||
}
|
||||
|
@ -22,15 +22,15 @@ object EnvMode {
|
||||
private val envName = "DOCSPELL_ENV"
|
||||
|
||||
case object Dev extends EnvMode {
|
||||
val isDev = true
|
||||
val isDev = true
|
||||
val isProd = false
|
||||
}
|
||||
case object Prod extends EnvMode {
|
||||
val isDev = false
|
||||
val isDev = false
|
||||
val isProd = true
|
||||
}
|
||||
|
||||
def dev: EnvMode = Dev
|
||||
def dev: EnvMode = Dev
|
||||
def prod: EnvMode = Prod
|
||||
|
||||
def fromString(s: String): Either[String, EnvMode] =
|
||||
|
@ -20,10 +20,10 @@ sealed trait EquipmentUse { self: Product =>
|
||||
object EquipmentUse {
|
||||
|
||||
case object Concerning extends EquipmentUse
|
||||
case object Disabled extends EquipmentUse
|
||||
case object Disabled extends EquipmentUse
|
||||
|
||||
def concerning: EquipmentUse = Concerning
|
||||
def disabled: EquipmentUse = Disabled
|
||||
def disabled: EquipmentUse = Disabled
|
||||
|
||||
val all: NonEmptyList[EquipmentUse] =
|
||||
NonEmptyList.of(concerning, disabled)
|
||||
|
@ -43,12 +43,12 @@ object Glob {
|
||||
}
|
||||
|
||||
private val separator = '/'
|
||||
private val anyChar = '|'
|
||||
private val anyChar = '|'
|
||||
|
||||
val all = new Glob {
|
||||
def matches(caseSensitive: Boolean)(in: String) = true
|
||||
def matchFilenameOrPath(in: String) = true
|
||||
val asString = "*"
|
||||
def matchFilenameOrPath(in: String) = true
|
||||
val asString = "*"
|
||||
}
|
||||
|
||||
def pattern(pattern: Pattern): Glob =
|
||||
@ -142,7 +142,7 @@ object Glob {
|
||||
}
|
||||
|
||||
def startsWith(prefix: String, caseSensitive: Boolean): Boolean = {
|
||||
val vstr = if (caseSensitive) str else str.toLowerCase
|
||||
val vstr = if (caseSensitive) str else str.toLowerCase
|
||||
val vprefix = if (caseSensitive) prefix else prefix.toLowerCase
|
||||
vstr.startsWith(vprefix)
|
||||
}
|
||||
|
@ -24,17 +24,17 @@ sealed trait ItemState { self: Product =>
|
||||
|
||||
object ItemState {
|
||||
|
||||
case object Premature extends ItemState
|
||||
case object Premature extends ItemState
|
||||
case object Processing extends ItemState
|
||||
case object Created extends ItemState
|
||||
case object Confirmed extends ItemState
|
||||
case object Deleted extends ItemState
|
||||
case object Created extends ItemState
|
||||
case object Confirmed extends ItemState
|
||||
case object Deleted extends ItemState
|
||||
|
||||
def premature: ItemState = Premature
|
||||
def premature: ItemState = Premature
|
||||
def processing: ItemState = Processing
|
||||
def created: ItemState = Created
|
||||
def confirmed: ItemState = Confirmed
|
||||
def deleted: ItemState = Deleted
|
||||
def created: ItemState = Created
|
||||
def confirmed: ItemState = Confirmed
|
||||
def deleted: ItemState = Deleted
|
||||
|
||||
def fromString(str: String): Either[String, ItemState] =
|
||||
str.toLowerCase match {
|
||||
|
@ -20,8 +20,7 @@ object JobState {
|
||||
/** Waiting for being executed. */
|
||||
case object Waiting extends JobState {}
|
||||
|
||||
/** A scheduler has picked up this job and will pass it to the next free slot.
|
||||
*/
|
||||
/** A scheduler has picked up this job and will pass it to the next free slot. */
|
||||
case object Scheduled extends JobState {}
|
||||
|
||||
/** Is currently executing */
|
||||
@ -39,17 +38,17 @@ object JobState {
|
||||
/** Finished with success */
|
||||
case object Success extends JobState {}
|
||||
|
||||
val waiting: JobState = Waiting
|
||||
val stuck: JobState = Stuck
|
||||
val waiting: JobState = Waiting
|
||||
val stuck: JobState = Stuck
|
||||
val scheduled: JobState = Scheduled
|
||||
val running: JobState = Running
|
||||
val failed: JobState = Failed
|
||||
val running: JobState = Running
|
||||
val failed: JobState = Failed
|
||||
val cancelled: JobState = Cancelled
|
||||
val success: JobState = Success
|
||||
val success: JobState = Success
|
||||
|
||||
val all: NonEmptyList[JobState] =
|
||||
NonEmptyList.of(Waiting, Scheduled, Running, Stuck, Failed, Cancelled, Success)
|
||||
val queued: Set[JobState] = Set(Waiting, Scheduled, Stuck)
|
||||
val queued: Set[JobState] = Set(Waiting, Scheduled, Stuck)
|
||||
val done: NonEmptyList[JobState] = NonEmptyList.of(Failed, Cancelled, Success)
|
||||
val notDone: NonEmptyList[JobState] = //all - done
|
||||
NonEmptyList.of(Waiting, Scheduled, Running, Stuck)
|
||||
|
@ -39,7 +39,7 @@ object JvmInfo {
|
||||
MemoryUsage.createHeap[F].flatMap { mu =>
|
||||
Sync[F].delay {
|
||||
val rmb = management.ManagementFactory.getRuntimeMXBean()
|
||||
val rt = Runtime.getRuntime()
|
||||
val rt = Runtime.getRuntime()
|
||||
JvmInfo(
|
||||
id,
|
||||
pidHost = rmb.getName(),
|
||||
@ -84,7 +84,7 @@ object JvmInfo {
|
||||
|
||||
def createHeap[F[_]: Sync]: F[MemoryUsage] =
|
||||
Sync[F].delay {
|
||||
val mxb = management.ManagementFactory.getMemoryMXBean()
|
||||
val mxb = management.ManagementFactory.getMemoryMXBean()
|
||||
val heap = mxb.getHeapMemoryUsage()
|
||||
MemoryUsage(
|
||||
init = math.max(0, heap.getInit()),
|
||||
|
@ -97,10 +97,10 @@ case class LenientUri(
|
||||
|
||||
def asString: String = {
|
||||
val schemePart = scheme.toList.mkString(":")
|
||||
val authPart = authority.map(a => s"//$a").getOrElse("")
|
||||
val pathPart = path.asString
|
||||
val queryPart = query.map(q => s"?$q").getOrElse("")
|
||||
val fragPart = fragment.map(f => s"#$f").getOrElse("")
|
||||
val authPart = authority.map(a => s"//$a").getOrElse("")
|
||||
val pathPart = path.asString
|
||||
val queryPart = query.map(q => s"?$q").getOrElse("")
|
||||
val fragPart = fragment.map(f => s"#$f").getOrElse("")
|
||||
s"$schemePart:$authPart$pathPart$queryPart$fragPart"
|
||||
}
|
||||
}
|
||||
@ -116,24 +116,24 @@ object LenientUri {
|
||||
}
|
||||
case object RootPath extends Path {
|
||||
val segments = Nil
|
||||
val isRoot = true
|
||||
val isEmpty = false
|
||||
val isRoot = true
|
||||
val isEmpty = false
|
||||
def /(seg: String): Path =
|
||||
NonEmptyPath(NonEmptyList.of(seg))
|
||||
def asString = "/"
|
||||
}
|
||||
case object EmptyPath extends Path {
|
||||
val segments = Nil
|
||||
val isRoot = false
|
||||
val isEmpty = true
|
||||
val isRoot = false
|
||||
val isEmpty = true
|
||||
def /(seg: String): Path =
|
||||
NonEmptyPath(NonEmptyList.of(seg))
|
||||
def asString = ""
|
||||
}
|
||||
case class NonEmptyPath(segs: NonEmptyList[String]) extends Path {
|
||||
def segments = segs.toList
|
||||
val isEmpty = false
|
||||
val isRoot = false
|
||||
val isEmpty = false
|
||||
val isRoot = false
|
||||
def /(seg: String): Path =
|
||||
copy(segs = segs.append(seg))
|
||||
def asString =
|
||||
@ -215,7 +215,7 @@ object LenientUri {
|
||||
case -1 =>
|
||||
Left(s"No scheme found: $str")
|
||||
case n =>
|
||||
val scheme = makeScheme(p0.substring(0, n))
|
||||
val scheme = makeScheme(p0.substring(0, n))
|
||||
val (path, query, frag) = splitPathQF(p0.substring(n + 1))
|
||||
scheme match {
|
||||
case None =>
|
||||
|
@ -17,8 +17,8 @@ sealed trait LogLevel { self: Product =>
|
||||
object LogLevel {
|
||||
|
||||
case object Debug extends LogLevel { val toInt = 0 }
|
||||
case object Info extends LogLevel { val toInt = 1 }
|
||||
case object Warn extends LogLevel { val toInt = 2 }
|
||||
case object Info extends LogLevel { val toInt = 1 }
|
||||
case object Warn extends LogLevel { val toInt = 2 }
|
||||
case object Error extends LogLevel { val toInt = 3 }
|
||||
|
||||
def fromInt(n: Int): LogLevel =
|
||||
|
@ -81,8 +81,7 @@ object MetaProposal {
|
||||
implicit val order: Order[Candidate] =
|
||||
Order.by(_.ref)
|
||||
|
||||
/** This deviates from standard order to sort None at last.
|
||||
*/
|
||||
/** This deviates from standard order to sort None at last. */
|
||||
val weightOrder: Order[Option[Double]] = new Order[Option[Double]] {
|
||||
def compare(x: Option[Double], y: Option[Double]) =
|
||||
(x, y) match {
|
||||
|
@ -20,7 +20,7 @@ import io.circe.generic.semiauto._
|
||||
*/
|
||||
case class MetaProposalList private (proposals: List[MetaProposal]) {
|
||||
|
||||
def isEmpty: Boolean = proposals.isEmpty
|
||||
def isEmpty: Boolean = proposals.isEmpty
|
||||
def nonEmpty: Boolean = proposals.nonEmpty
|
||||
|
||||
def hasResults(mt: MetaProposalType, mts: MetaProposalType*): Boolean =
|
||||
@ -115,7 +115,7 @@ object MetaProposalList {
|
||||
MetaProposal
|
||||
) => Map[MetaProposalType, MetaProposal]
|
||||
): MetaProposalList = {
|
||||
val init = Map.empty[MetaProposalType, MetaProposal]
|
||||
val init = Map.empty[MetaProposalType, MetaProposal]
|
||||
val merged = ml.foldLeft(init)((map, el) => el.proposals.foldLeft(map)(merge))
|
||||
fromMap(merged)
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ sealed trait MetaProposalType { self: Product =>
|
||||
|
||||
object MetaProposalType {
|
||||
|
||||
case object CorrOrg extends MetaProposalType
|
||||
case object CorrOrg extends MetaProposalType
|
||||
case object CorrPerson extends MetaProposalType
|
||||
case object ConcPerson extends MetaProposalType
|
||||
case object ConcEquip extends MetaProposalType
|
||||
case object DocDate extends MetaProposalType
|
||||
case object DueDate extends MetaProposalType
|
||||
case object ConcEquip extends MetaProposalType
|
||||
case object DocDate extends MetaProposalType
|
||||
case object DueDate extends MetaProposalType
|
||||
|
||||
val all: List[MetaProposalType] =
|
||||
List(CorrOrg, CorrPerson, ConcPerson, ConcEquip, DocDate, DueDate)
|
||||
|
@ -15,8 +15,7 @@ import docspell.common.syntax.all._
|
||||
|
||||
import io.circe.{Decoder, Encoder}
|
||||
|
||||
/** A MIME Type impl with just enough features for the use here.
|
||||
*/
|
||||
/** A MIME Type impl with just enough features for the use here. */
|
||||
case class MimeType(primary: String, sub: String, params: Map[String, String]) {
|
||||
def withParam(name: String, value: String): MimeType =
|
||||
copy(params = params.updated(name, value))
|
||||
@ -99,13 +98,13 @@ object MimeType {
|
||||
parse(str).throwLeft
|
||||
|
||||
val octetStream = application("octet-stream")
|
||||
val pdf = application("pdf")
|
||||
val zip = application("zip")
|
||||
val png = image("png")
|
||||
val jpeg = image("jpeg")
|
||||
val tiff = image("tiff")
|
||||
val html = text("html")
|
||||
val plain = text("plain")
|
||||
val pdf = application("pdf")
|
||||
val zip = application("zip")
|
||||
val png = image("png")
|
||||
val jpeg = image("jpeg")
|
||||
val tiff = image("tiff")
|
||||
val html = text("html")
|
||||
val plain = text("plain")
|
||||
val emls = NonEmptyList.of(
|
||||
MimeType("message", "rfc822", Map.empty),
|
||||
application("mbox")
|
||||
|
@ -17,12 +17,12 @@ sealed trait NerTag { self: Product =>
|
||||
object NerTag {
|
||||
|
||||
case object Organization extends NerTag
|
||||
case object Person extends NerTag
|
||||
case object Location extends NerTag
|
||||
case object Misc extends NerTag
|
||||
case object Email extends NerTag
|
||||
case object Website extends NerTag
|
||||
case object Date extends NerTag
|
||||
case object Person extends NerTag
|
||||
case object Location extends NerTag
|
||||
case object Misc extends NerTag
|
||||
case object Email extends NerTag
|
||||
case object Website extends NerTag
|
||||
case object Date extends NerTag
|
||||
|
||||
val all: List[NerTag] = List(Organization, Person, Location)
|
||||
|
||||
|
@ -12,10 +12,10 @@ sealed trait NlpMode { self: Product =>
|
||||
self.productPrefix
|
||||
}
|
||||
object NlpMode {
|
||||
case object Full extends NlpMode
|
||||
case object Basic extends NlpMode
|
||||
case object Full extends NlpMode
|
||||
case object Basic extends NlpMode
|
||||
case object RegexOnly extends NlpMode
|
||||
case object Disabled extends NlpMode
|
||||
case object Disabled extends NlpMode
|
||||
|
||||
def fromString(name: String): Either[String, NlpMode] =
|
||||
name.toLowerCase match {
|
||||
|
@ -16,7 +16,7 @@ sealed trait NodeType { self: Product =>
|
||||
object NodeType {
|
||||
|
||||
case object Restserver extends NodeType
|
||||
case object Joex extends NodeType
|
||||
case object Joex extends NodeType
|
||||
|
||||
def fromString(str: String): Either[String, NodeType] =
|
||||
str.toLowerCase match {
|
||||
|
@ -20,10 +20,10 @@ sealed trait OrgUse { self: Product =>
|
||||
object OrgUse {
|
||||
|
||||
case object Correspondent extends OrgUse
|
||||
case object Disabled extends OrgUse
|
||||
case object Disabled extends OrgUse
|
||||
|
||||
def correspondent: OrgUse = Correspondent
|
||||
def disabled: OrgUse = Disabled
|
||||
def disabled: OrgUse = Disabled
|
||||
|
||||
val all: NonEmptyList[OrgUse] =
|
||||
NonEmptyList.of(correspondent, disabled)
|
||||
|
@ -20,13 +20,13 @@ sealed trait PersonUse { self: Product =>
|
||||
object PersonUse {
|
||||
|
||||
case object Correspondent extends PersonUse
|
||||
case object Concerning extends PersonUse
|
||||
case object Both extends PersonUse
|
||||
case object Disabled extends PersonUse
|
||||
case object Concerning extends PersonUse
|
||||
case object Both extends PersonUse
|
||||
case object Disabled extends PersonUse
|
||||
|
||||
def concerning: PersonUse = Concerning
|
||||
def concerning: PersonUse = Concerning
|
||||
def correspondent: PersonUse = Correspondent
|
||||
def both: PersonUse = Both
|
||||
def both: PersonUse = Both
|
||||
|
||||
val concerningAndBoth: NonEmptyList[PersonUse] =
|
||||
NonEmptyList.of(Concerning, Both)
|
||||
|
@ -8,8 +8,7 @@ package docspell.common
|
||||
|
||||
import scala.concurrent.ExecutionContext
|
||||
|
||||
/** Captures thread pools to use in an application.
|
||||
*/
|
||||
/** Captures thread pools to use in an application. */
|
||||
case class Pools(
|
||||
connectEC: ExecutionContext,
|
||||
httpClientEC: ExecutionContext,
|
||||
|
@ -20,9 +20,9 @@ sealed trait SearchMode { self: Product =>
|
||||
|
||||
object SearchMode {
|
||||
|
||||
final case object Normal extends SearchMode
|
||||
final case object Normal extends SearchMode
|
||||
final case object Trashed extends SearchMode
|
||||
final case object All extends SearchMode
|
||||
final case object All extends SearchMode
|
||||
|
||||
def fromString(str: String): Either[String, SearchMode] =
|
||||
str.toLowerCase match {
|
||||
|
@ -49,7 +49,7 @@ object SystemCommand {
|
||||
startProcess(cmd, wd, logger, stdin) { proc =>
|
||||
Stream.eval {
|
||||
for {
|
||||
_ <- writeToProcess(stdin, proc)
|
||||
_ <- writeToProcess(stdin, proc)
|
||||
term <- Sync[F].blocking(proc.waitFor(cmd.timeout.seconds, TimeUnit.SECONDS))
|
||||
_ <-
|
||||
if (term)
|
||||
@ -93,7 +93,7 @@ object SystemCommand {
|
||||
)(
|
||||
f: Process => Stream[F, A]
|
||||
): Stream[F, A] = {
|
||||
val log = logger.debug(s"Running external command: ${cmd.cmdString}")
|
||||
val log = logger.debug(s"Running external command: ${cmd.cmdString}")
|
||||
val hasStdin = stdin.take(1).compile.last.map(_.isDefined)
|
||||
val proc = log *> hasStdin.flatMap(flag =>
|
||||
Sync[F].blocking {
|
||||
|
@ -32,7 +32,7 @@ object ThreadFactories {
|
||||
|
||||
def ofNameFJ(prefix: String): ForkJoinWorkerThreadFactory =
|
||||
new ForkJoinWorkerThreadFactory {
|
||||
val tf = ForkJoinPool.defaultForkJoinWorkerThreadFactory
|
||||
val tf = ForkJoinPool.defaultForkJoinWorkerThreadFactory
|
||||
val counter = new AtomicLong(0)
|
||||
|
||||
def newThread(pool: ForkJoinPool): ForkJoinWorkerThread = {
|
||||
|
@ -27,7 +27,7 @@ trait StreamSyntax {
|
||||
optStr
|
||||
.map(_.trim)
|
||||
.toRight(new Exception("Empty string cannot be parsed into a value"))
|
||||
json <- parse(str).leftMap(_.underlying)
|
||||
json <- parse(str).leftMap(_.underlying)
|
||||
value <- json.as[A]
|
||||
} yield value
|
||||
)
|
||||
|
@ -20,7 +20,7 @@ trait StringSyntax {
|
||||
|
||||
def parseJsonAs[A](implicit d: Decoder[A]): Either[Throwable, A] =
|
||||
for {
|
||||
json <- parse(s).leftMap(_.underlying)
|
||||
json <- parse(s).leftMap(_.underlying)
|
||||
value <- json.as[A]
|
||||
} yield value
|
||||
}
|
||||
|
Reference in New Issue
Block a user