Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
agilesteel committed Nov 27, 2023
0 parents commit f6a4ee7
Show file tree
Hide file tree
Showing 43 changed files with 954 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# https://EditorConfig.org

root = true

[*]
charset = utf-8
end_of_line = unset
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
12 changes: 12 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# These are supported funding model platforms

github: [devinsideyou]
patreon: devinsideyou
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
*.worksheet.sc
.ammonite/
.bloop/
.bsp/
.dotty-ide*
.history/
.idea/
.metals/
.scala-build/
.scala/
.vscode/
metals.sbt
target/
6 changes: 6 additions & 0 deletions .jvmopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-XX:MaxMetaspaceSize=2g
-XX:ReservedCodeCacheSize=1g
-Xms1g
-Xmx12g
-XshowSettings:vm
-Xss4m
40 changes: 40 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
rules = [
# ExplicitResultTypes
LeakingImplicitClassVal
NoValInForComprehension
OrganizeImports
# RemoveUnused
]

ExplicitResultTypes {
memberKind = [Def, Val, Var]
memberVisibility = [Public, Protected]
skipSimpleDefinitions = ['Term.Ref', 'Lit', 'Term.New']
fatalWarnings = false
rewriteStructuralTypesToNamedSubclass = false
}

OrganizeImports {
blankLines = Auto
coalesceToWildcardImportThreshold = 1
expandRelative = true
groupExplicitlyImportedImplicitsSeparately = false
groupedImports = AggressiveMerge
groups = [
"re:javax?\\."
"scala."
"*"
"dev.insideyou."
]
importSelectorsOrder = Ascii
importsOrder = Ascii
preset = DEFAULT
removeUnused = false // should be true
}

RemoveUnused {
imports = false
privates = true
locals = true
patternvars = true
}
172 changes: 172 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
version = "3.7.17"

align {
preset = none
stripMargin = yes
}

assumeStandardLibraryStripMargin = no

danglingParentheses {
exclude = []
}

docstrings {
forceBlankLineBefore = no
oneline = keep
style = SpaceAsterisk
wrap = no
}

fileOverride {
"glob:**/*.sbt" {
newlines {
topLevelStatementBlankLines = [
{
blanks {
afterAll = -1,
}

minBreaks = 0
}
]
}

runner {
# https://scalameta.org/scalafmt/docs/configuration.html#scala-dialects
dialect = Scala212
}
}

"glob:**/project/*.scala" {
newlines {
topLevelStatementBlankLines = [
{
blanks {
afterAll = -1,
}

minBreaks = 0
}
]
}

runner {
# https://scalameta.org/scalafmt/docs/configuration.html#scala-dialects
dialect = Scala212
}
}
}

includeNoParensInSelectChains = yes

indent {
caseSite = 5
commaSiteRelativeToExtends = 8
ctrlSite = 4
defnSite = 2
withSiteRelativeToExtends = 3
}

indentOperator {
exemptScope = all
}

lineEndings = preserve

maxColumn = 100

newlines {
alwaysBeforeElseAfterCurlyIf = yes
avoidInResultType = yes
avoidForSimpleOverflow = [slc]
beforeCurlyLambdaParams = multilineWithCaseOnly
implicitParamListModifierForce = [after]
inInterpolation = avoid

topLevelStatementBlankLines = [
{
blanks {
beforeAll = -1,
afterAll = 1,
beforeEndMarker = -1
}

minBreaks = 0
},
{
blanks {
beforeAll = -1,
before = 1,
after = 1,
afterAll = -1,
beforeEndMarker = -1
}

minBreaks = 1
}
]
}

project {
excludeFilters = [
".metals"
]
}

rewrite {
redundantBraces {
ifElseExpressions = yes
}

rules = [
PreferCurlyFors
RedundantBraces
RedundantParens
SortModifiers
]

scala3 {
convertToNewSyntax = yes
removeEndMarkerMaxLines = 28
removeOptionalBraces = oldSyntaxToo
}

sortModifiers {
order = [
inline
final
sealed
abstract
override
implicit
private
protected
lazy
infix
]
}
}

rewriteTokens {
"⇒" = "=>"
"→" = "->"
"←" = "<-"
}

runner {
# https://scalameta.org/scalafmt/docs/configuration.html#scala-dialects
dialect = scala3
}

spaces {
inImportCurlyBraces = yes
}

trailingCommas = multiple

verticalMultiline {
arityThreshold = 3
atDefnSite = yes
newlineAfterOpenParen = yes
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package dev.insideyou
package play3
package usecase1

trait Boundary:
def currentTime: UIO[LocalTime]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package dev.insideyou
package play3
package usecase1

object BusinessLogic:
lazy val make: Boundary =
new:
override lazy val currentTime =
ZIO.succeed(java.time.LocalTime.now.nn)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package dev.insideyou
package play3
package usecase1

export java.time.LocalTime
8 changes: 8 additions & 0 deletions 01-core/src/test/scala/dev/insideyou/play3/ExampleSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.insideyou
package play3

final class ExampleSuite extends TestSuite:
test("hello world"):
forAll: (int: Int, string: String) =>
expectEquals(int, int)
expectEquals(string, string)
72 changes: 72 additions & 0 deletions 01-core/src/test/scala/dev/insideyou/play3/Expectations.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package dev.insideyou
package play3

import scala.Console.*

import com.eed3si9n.expecty.Expecty
import munit.internal.console.StackTraces.dropInside

@SuppressWarnings(Array("org.wartremover.warts.All"))
trait Expectations:
this: munit.FunSuite =>
inline def expect(
inline cond: Boolean,
clue: => Any = "assertion failed",
)(using
loc: munit.Location
): Unit =
lazy val calculatedClue =
val expectyClue =
try { Expecty.assert(cond); "" }
catch Expectations.ExtractMessage

if expectyClue.isEmpty then s"$RED\n$clue$RESET"
else s"$RED\n$clue\n$expectyClue$RESET"

assert(cond, calculatedClue)

def expectEquals[A, B](
obtained: A,
expected: B,
clue: => Any = "values are not the same",
)(using
loc: munit.Location,
ev: B <:< A,
): Unit =
lazy val calculatedClue =
val expectyClue =
try { Expecty.assert(obtained == expected); "" }
catch Expectations.ExtractMessage

if expectyClue.isEmpty then s"$RED\n$clue$RESET"
else s"$RED\n$clue\n$expectyClue$RESET"

assertEquals(obtained, expected, calculatedClue)

def expectNotEquals[A, B](
obtained: A,
expected: B,
clue: => Any = "values are the same",
)(using
loc: munit.Location,
ev: A =:= B,
): Unit =
lazy val calculatedClue =
val expectyClue =
try { Expecty.assert(obtained != expected); "" }
catch Expectations.ExtractMessage

val clueWithSuffix =
s"${munitPrint(clue)} expected same: $expected was not: $obtained"

if expectyClue.isEmpty then clueWithSuffix
else s"$RED\n$clueWithSuffix\n$expectyClue$RESET"

dropInside(if obtained == expected then failComparison(calculatedClue, obtained, expected))

object Expectations:
private val ExtractMessage: PartialFunction[Throwable, String] =
case e: AssertionError =>
// it's in a try/catch because of .nn
try e.getMessage.nn.split("\n").nn.slice(2, Int.MaxValue).mkString("\n", "\n", "\n")
catch case scala.util.control.NonFatal(_) => ""
8 changes: 8 additions & 0 deletions 01-core/src/test/scala/dev/insideyou/play3/TestSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package dev.insideyou
package play3

export org.scalacheck.Arbitrary
export org.scalacheck.Cogen
export org.scalacheck.Gen

trait TestSuite extends munit.DisciplineSuite, Expectations
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package dev.insideyou
package play3

trait FancyController(
using
override protected val controllerComponents: ControllerComponents
) extends BaseController
Loading

0 comments on commit f6a4ee7

Please sign in to comment.