Skip to content

Commit e5f2672

Browse files
authored
Use Scalafmt code formatter (#983)
* Install spotless plugin * Apply code style * Add .git-blame-ignore-revs * Fix readme
1 parent d719043 commit e5f2672

File tree

387 files changed

+24979
-12033
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

387 files changed

+24979
-12033
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Scalafmt apply
2+
7fb89c767649f28c0405d5f4ba8afa181614504f

README.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ import org.opencypher.morpheus.api.MorpheusSession
113113
import org.opencypher.morpheus.api.io.{MorpheusNodeTable, MorpheusRelationshipTable}
114114
import org.opencypher.morpheus.util.App
115115

116-
/**
117-
* Demonstrates basic usage of the Morpheus API by loading an example graph from [[DataFrame]]s.
118-
*/
116+
/** Demonstrates basic usage of the Morpheus API by loading an example graph from [[DataFrame]]s. */
119117
object DataFrameInputExample extends App {
120118
// 1) Create Morpheus session and retrieve Spark session
121119
implicit val morpheus: MorpheusSession = MorpheusSession.local()
@@ -124,15 +122,23 @@ object DataFrameInputExample extends App {
124122
import spark.sqlContext.implicits._
125123

126124
// 2) Generate some DataFrames that we'd like to interpret as a property graph.
127-
val nodesDF = spark.createDataset(Seq(
128-
(0L, "Alice", 42L),
129-
(1L, "Bob", 23L),
130-
(2L, "Eve", 84L)
131-
)).toDF("id", "name", "age")
132-
val relsDF = spark.createDataset(Seq(
133-
(0L, 0L, 1L, "23/01/1987"),
134-
(1L, 1L, 2L, "12/12/2009")
135-
)).toDF("id", "source", "target", "since")
125+
val nodesDF = spark
126+
.createDataset(
127+
Seq(
128+
(0L, "Alice", 42L),
129+
(1L, "Bob", 23L),
130+
(2L, "Eve", 84L)
131+
)
132+
)
133+
.toDF("id", "name", "age")
134+
val relsDF = spark
135+
.createDataset(
136+
Seq(
137+
(0L, 0L, 1L, "23/01/1987"),
138+
(1L, 1L, 2L, "12/12/2009")
139+
)
140+
)
141+
.toDF("id", "source", "target", "since")
136142

137143
// 3) Generate node- and relationship tables that wrap the DataFrames. The mapping between graph elements and columns
138144
// is derived using naming conventions for identifier columns.
@@ -147,7 +153,8 @@ object DataFrameInputExample extends App {
147153

148154
// 6) Collect results into string by selecting a specific column.
149155
// This operation may be very expensive as it materializes results locally.
150-
val names: Set[String] = result.records.table.df.collect().map(_.getAs[String]("n_name")).toSet
156+
val names: Set[String] =
157+
result.records.table.df.collect().map(_.getAs[String]("n_name")).toSet
151158

152159
println(names)
153160
}

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ plugins {
33

44
alias(libs.plugins.champeau.jmh).apply(false)
55
alias(libs.plugins.license).apply(false)
6-
alias(libs.plugins.scalastyle).apply(false)
76
alias(libs.plugins.shadowjar).apply(false)
7+
alias(libs.plugins.spotless).apply(false)
88

99
alias(libs.plugins.versionCatalogUpdate)
1010
}

build.style.gradle

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
subprojects {
2-
apply plugin: 'com.github.alisiikh.scalastyle'
2+
apply plugin: 'com.diffplug.spotless'
33

4-
scalastyle {
5-
scalaVersion = libs.versions.scala.major.get()
6-
config = rootProject.file("etc/scalastyle_config.xml")
4+
spotless {
5+
scala {
6+
scalafmt().configFile(rootProject.file('etc/.scalafmt.conf'))
7+
}
78
}
89
}

etc/.scalafmt.conf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version = 3.8.1
2+
runner.dialect = scala212
3+
4+
maxColumn = 100
5+
indent.defnSite = 2
6+
7+
docstrings.style = SpaceAsterisk
8+
docstrings.oneline = fold
9+
docstrings.blankFirstLine = yes

etc/scalastyle_config.xml

Lines changed: 0 additions & 16 deletions
This file was deleted.

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mockito = "5.18.0"
1919
neo4j-driver = "1.7.2"
2020
netty = "4.2.7.Final"
2121
# @pin - let's prevent automatic updates for the moment
22-
scala-full = "2.12.20"
22+
scala-full = "2.12.20" # Note, needs to stay aligned with scalafmt.conf
2323
# @pin - let's prevent automatic updates for the moment
2424
scala-major = "2.12"
2525
scalacheck = "1.19.0"
@@ -83,6 +83,6 @@ testing-scalatest-junit = { module = "org.scalatestplus:junit-5-13_2.12", versio
8383
champeau-jmh = "me.champeau.jmh:0.7.3"
8484
# @pin - version is self-hosted
8585
license = "com.github.hierynomus.license:0.16.3-63da64d"
86-
scalastyle = "com.github.alisiikh.scalastyle:3.5.0"
86+
spotless = "com.diffplug.spotless:8.1.0"
8787
shadowjar = "com.gradleup.shadow:9.2.2"
8888
versionCatalogUpdate = "nl.littlerobots.version-catalog-update:1.0.1"

0 commit comments

Comments
 (0)