Skip to content

Commit

Permalink
Merge pull request #122 from mdedetrich/add-and-appply-scalafmt
Browse files Browse the repository at this point in the history
Add and apply scalafmt
  • Loading branch information
mdedetrich authored Jan 26, 2024
2 parents 77714f6 + b496e71 commit c0eac3b
Show file tree
Hide file tree
Showing 33 changed files with 334 additions and 272 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Scalafmt

permissions: {}

on:
pull_request:
branches: ['**']

jobs:
build:
name: Code is formatted
runs-on: ubuntu-latest
steps:
- name: Checkout current branch (full)
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false

- name: Check project is formatted
uses: jrouly/scalafmt-native-action@v3
with:
arguments: '--list --mode diff-ref=origin/main'
26 changes: 26 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version = 3.7.17
runner.dialect = scala212
maxColumn = 120
project.git = true

# http://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style.
# scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala
docstrings.style = Asterisk

# This also seems more idiomatic to include whitespace in import x.{ yyy }
spaces.inImportCurlyBraces = true

align.tokens."+" = [
{
code = "%"
owners = [
{ regex = "Term.ApplyInfix" }
]
},
{
code = "%%"
owners = [
{ regex = "Term.ApplyInfix" }
]
}
]
9 changes: 5 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ ThisBuild / dynverSonatypeSnapshots := true

// So that publishLocal doesn't continuously create new versions
def versionFmt(out: sbtdynver.GitDescribeOutput): String = {
val snapshotSuffix = if
(out.isSnapshot()) "-SNAPSHOT"
else ""
val snapshotSuffix =
if (out.isSnapshot()) "-SNAPSHOT"
else ""
out.ref.dropPrefix + snapshotSuffix
}

Expand Down Expand Up @@ -55,7 +55,8 @@ scalacOptions ++= Seq(
"-unchecked",
"-deprecation",
"-Xlint",
"-encoding", "UTF-8"
"-encoding",
"UTF-8"
)
scriptedLaunchOpts += "-Xmx1024m"
scriptedLaunchOpts ++= Seq("-Dplugin.version=" + version.value)
Expand Down
7 changes: 2 additions & 5 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ object Library {

// Libraries
val bndLib = "biz.aQute.bnd" % "biz.aQute.bndlib" % bndVersion
val specs2 = "org.specs2" %% "specs2-core" % specs2Version
val specs2 = "org.specs2" %% "specs2-core" % specs2Version
}

object Dependencies {

import Library._

val sbtOsgi = List(
bndLib,
specs2 % Test)
val sbtOsgi = List(bndLib, specs2 % Test)
}
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("com.github.sbt" % "sbt-ci-release" % "1.5.12")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
addSbtPlugin("com.github.sbt" % "sbt-github-actions" % "0.22.0")
Loading

0 comments on commit c0eac3b

Please sign in to comment.