Task project template

This commit is contained in:
Anton Brovkin 2023-02-11 19:53:42 +03:00
parent efa65652d2
commit 177cf65c81
5 changed files with 53 additions and 0 deletions

8
.scalafmt.conf Normal file
View file

@ -0,0 +1,8 @@
binPack.parentConstructors = true
maxColumn = 120
includeCurlyBraceInSelectChains = false
align = most
version = "2.4.2"
trailingCommas = preserve
newlines.penalizeSingleSelectMultiArgList = false
newlines.alwaysBeforeMultilineDef = false

21
build.sbt Normal file
View file

@ -0,0 +1,21 @@
import _root_.sbt.Keys._
import wartremover.Wart
import wartremover.Wart._
name := "bachelor-homeworks"
version := "0.1"
scalaVersion := "2.13.10"
scalacOptions := List(
"-encoding",
"utf8",
"-feature",
"-unchecked",
"-deprecation",
"-language:_",
"-Ymacro-annotations"
)
libraryDependencies += "org.scalatest" %% "scalatest" % "3.2.0" % "test"
wartremoverErrors ++= Seq[Wart](Any, AsInstanceOf, Null, Return, Throw, While, MutableDataStructures)

1
project/build.properties Normal file
View file

@ -0,0 +1 @@
sbt.version=1.6.2

1
project/plugins.sbt Normal file
View file

@ -0,0 +1 @@
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.0.9")

View file

@ -0,0 +1,22 @@
package mipt.utils
object Homeworks {
final case class TaskNotDone(num: String, text: String)
extends RuntimeException(s"выполните задание $num : \n $text")
trait TaskDef {
def applySeq(num: Seq[Int]): Nothing
def apply(num: Int*): Nothing = applySeq(num)
}
@SuppressWarnings(Array("org.wartremover.warts.Throw"))
implicit class TaskSyntax(private val cs: StringContext) extends AnyVal {
def task(refs: Any*): TaskDef = xs => {
val message = cs.s(refs: _*).stripMargin
throw TaskNotDone(xs.mkString("."), message)
}
}
}