Skip to content

Commit 2574f1b

Browse files
committed
Add Named arguments example
1 parent cb0fe05 commit 2574f1b

24 files changed

+247
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
target/
2+
boot/
3+
lib_managed/
4+
src_managed/
5+
project/plugins/project/
6+
7+
# Application log file and compressed previous logs (see conf/logback.xml)
8+
var/log/app_log.json
9+
var/log/app_log-*.gz
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
style = default
2+
3+
# Do not indent arguments based on the parent lenght
4+
align.openParenCallSite = false
5+
align.openParenDefnSite = false
6+
# Align any other statement (assigns, SBT dependencies, tuples, etc)
7+
align = more
8+
# Do not indent with 4 spaces for call + defn site
9+
continuationIndent.callSite = 2
10+
continuationIndent.defnSite = 2
11+
# Function definition argument list closing parentheses in a new line
12+
danglingParentheses = true
13+
importSelectors = singleLine
14+
maxColumn = 120
15+
project.excludeFilters = ["target/"]
16+
runner.optimizer.forceConfigStyleMinArgCount = 1
17+
rewrite.rules = [SortImports]
18+
19+
# Only format files tracked by git.
20+
project.git = true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
name := "CodelyTV Named Arguments example"
2+
version := "1.0"
3+
4+
Configuration.settings
5+
6+
libraryDependencies ++= Dependencies.production
7+
libraryDependencies ++= Dependencies.test
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<configuration>
3+
<appender name="stdOut" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
5+
<pattern>
6+
%highlight([%level]) [%date{HH:mm:ss.SSS}] [%class{0}#%method:%line] %message \(%mdc\) %n%throwable
7+
</pattern>
8+
</encoder>
9+
</appender>
10+
11+
<appender name="jsonFile" class="ch.qos.logback.core.rolling.RollingFileAppender">
12+
<file>var/log/app_log.json</file>
13+
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
14+
<fileNamePattern>var/log/app_log-%d{yyyy-MM-dd}.gz</fileNamePattern>
15+
<maxHistory>10</maxHistory>
16+
</rollingPolicy>
17+
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
18+
</appender>
19+
20+
<logger name="ch.qos.logback" level="WARN"/>
21+
22+
<root level="all">
23+
<appender-ref ref="stdOut"/>
24+
<appender-ref ref="jsonFile"/>
25+
</root>
26+
</configuration>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import sbt.{Tests, _}
2+
import sbt.Keys._
3+
4+
object Configuration {
5+
val settings = Seq(
6+
organization := "tv.codely",
7+
scalaVersion := "2.12.4",
8+
// Custom folders path (/src/main/scala and /src/test/scala by default)
9+
Compile / mainClass := Some("tv.codely.scala_http_api.entry_point.ScalaHttpApi"),
10+
Compile / scalaSource := baseDirectory.value / "/src/main/scala",
11+
Test / scalaSource := baseDirectory.value / "/src/test/scala",
12+
Compile / resourceDirectory := baseDirectory.value / "conf",
13+
// Compiler options. More information: https://tpolecat.github.io/2017/04/25/scalac-flags.html
14+
javaOptions += "-Duser.timezone=UTC",
15+
scalacOptions ++= Seq(
16+
"-deprecation", // Emit warning and location for usages of deprecated APIs.
17+
"-encoding",
18+
"utf-8", // Specify character encoding used by source files.
19+
"-explaintypes", // Explain type errors in more detail.
20+
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
21+
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
22+
"-language:experimental.macros", // Allow macro definition (besides implementation and application)
23+
"-language:higherKinds", // Allow higher-kinded types
24+
"-language:implicitConversions", // Allow definition of implicit functions called views
25+
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
26+
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
27+
"-Xfatal-warnings", // Fail the compilation if there are any warnings.
28+
"-Xfuture", // Turn on future language features.
29+
"-Xlint:adapted-args", // Warn if an argument list is modified to match the receiver.
30+
"-Xlint:by-name-right-associative", // By-name parameter of right associative operator.
31+
"-Xlint:constant", // Evaluation of a constant arithmetic expression results in an error.
32+
"-Xlint:delayedinit-select", // Selecting member of DelayedInit.
33+
"-Xlint:doc-detached", // A Scaladoc comment appears to be detached from its element.
34+
"-Xlint:inaccessible", // Warn about inaccessible types in method signatures.
35+
"-Xlint:infer-any", // Warn when a type argument is inferred to be `Any`.
36+
"-Xlint:missing-interpolator", // A string literal appears to be missing an interpolator id.
37+
"-Xlint:nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
38+
"-Xlint:nullary-unit", // Warn when nullary methods return Unit.
39+
"-Xlint:option-implicit", // Option.apply used implicit view.
40+
"-Xlint:package-object-classes", // Class or object defined in package object.
41+
"-Xlint:poly-implicit-overload", // Parameterized overloaded implicit methods are not visible as view bounds.
42+
"-Xlint:private-shadow", // A private field (or class parameter) shadows a superclass field.
43+
"-Xlint:stars-align", // Pattern sequence wildcard must align with sequence component.
44+
"-Xlint:type-parameter-shadow", // A local type parameter shadows a type already in scope.
45+
"-Xlint:unsound-match", // Pattern match may not be typesafe.
46+
"-Yno-adapted-args", // Do not adapt an argument list (either by inserting () or creating a tuple) to match the receiver.
47+
"-Ypartial-unification", // Enable partial unification in type constructor inference
48+
"-Ywarn-dead-code", // Warn when dead code is identified.
49+
"-Ywarn-extra-implicit", // Warn when more than one implicit parameter section is defined.
50+
"-Ywarn-inaccessible", // Warn about inaccessible types in method signatures.
51+
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
52+
"-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
53+
"-Ywarn-nullary-unit", // Warn when nullary methods return Unit.
54+
"-Ywarn-numeric-widen", // Warn when numerics are widened.
55+
"-Ywarn-unused:implicits", // Warn if an implicit parameter is unused.
56+
"-Ywarn-unused:imports", // Warn if an import selector is not referenced.
57+
"-Ywarn-unused:locals", // Warn if a local definition is unused.
58+
"-Ywarn-unused:params", // Warn if a value parameter is unused.
59+
"-Ywarn-unused:patvars", // Warn if a variable bound in a pattern is unused.
60+
"-Ywarn-unused:privates", // Warn if a private member is unused.
61+
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
62+
),
63+
Compile / console / scalacOptions --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings"), // Leave the console REPL usable :P
64+
Compile / run / scalacOptions -= "-Xcheckinit", // Expensive to run in prod
65+
Test / compile / scalacOptions --= Seq("-Xfatal-warnings"), // Due to deprecated ETA expansion used with ScalaMock
66+
// Test options
67+
Test / parallelExecution := false,
68+
Test / testForkedParallel := false,
69+
Test / fork := true,
70+
Test / testOptions ++= Seq(
71+
Tests.Argument(TestFrameworks.ScalaTest, "-u", "target/test-reports"), // Save test reports
72+
Tests.Argument("-oDF") // Show full stack traces and time spent in each test
73+
)
74+
)
75+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import sbt._
2+
3+
object Dependencies {
4+
5+
object Versions {
6+
val akka = "2.5.9"
7+
val akkaHttp = "10.0.11"
8+
}
9+
10+
val production = Seq(
11+
"com.typesafe.scala-logging" %% "scala-logging" % "3.7.2",
12+
"net.logstash.logback" % "logstash-logback-encoder" % "4.11"
13+
)
14+
15+
val test = Seq(
16+
"org.scalatest" %% "scalatest" % "3.0.5" % Test
17+
)
18+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=1.1.4
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "1.4.0")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
case class User(id: UserId, name: UserName)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
case class UserId(value: UUID)

0 commit comments

Comments
 (0)