Skip to content

Commit a9f853a

Browse files
authored
Merge pull request #630 from xuwei-k/scalafmt
add scalafmt-sbt. update scalafmt config
2 parents af33342 + 16f0742 commit a9f853a

32 files changed

Lines changed: 168 additions & 133 deletions

.github/workflows/build-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
cmd: |
4343
# Clone generated docs so that we can run some integration tests
4444
git clone -o origin https://github.com/playframework/play-generated-docs.git $PWD/data/generated
45-
sbt ++$MATRIX_SCALA test
45+
sbt ++$MATRIX_SCALA scalafmtSbtCheck scalafmtCheckAll test
4646
4747
finish:
4848
name: Finish

.scalafmt.conf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
align = more
1+
runner.dialect = Scala3
2+
align.preset = more
23
assumeStandardLibraryStripMargin = true
3-
danglingParentheses = true
4-
docstrings = JavaDoc
4+
danglingParentheses.preset = true
5+
docstrings.style = keep
56
maxColumn = 112
67
project.git = true
78
rewrite.rules = [ AvoidInfix, ExpandImportSelectors, RedundantParens, SortModifiers, PreferCurlyFors ]

app/actors/DocumentationActor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ class DocumentationActor(
395395
* Get the translation context for the given language and version.
396396
*/
397397
def translationContext(lang: Lang, version: Version, translation: Translation): TranslationContext = {
398-
val isDefault = lang == documentation.defaultLang
398+
val isDefault = lang == documentation.defaultLang
399399
val defaultAlternative = AlternateTranslation(
400400
documentation.defaultLang,
401401
true,

app/actors/DocumentationLoadingActor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ object DocumentationLoadingActor {
6969
val sheets = sortedSheets.flatMap { file =>
7070
repo.loadFile(s"cheatsheets/$category/$file")(is => Textile.toHTML(IOUtils.toString(is, "utf-8")))
7171
}
72-
val title = CheatSheetHelper.getCategoryTitle(category)
72+
val title = CheatSheetHelper.getCategoryTitle(category)
7373
val otherCategories = CheatSheetHelper
7474
.listCategoriesAndTitles(
7575
repo

app/actors/DocumentationPollingActor.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class DocumentationPollingActor(
119119
old.flatMap(_.default.byVersion.get(version)) match {
120120
// The version hasn't changed, don't rescan
121121
case Some(same: TranslationVersion) if same.cacheId == newCacheId => same
122-
case _ =>
122+
case _ =>
123123
implicit val lang = repos.default.config.lang
124124

125125
if (old.isDefined) {
@@ -144,15 +144,15 @@ class DocumentationPollingActor(
144144
// Now for each translation
145145
val translations = repos.translations.map { t =>
146146
// Parse all the versions from tags, branches and the main version
147-
val gitTags = parseVersionsFromRefs(t.repo.allTags).map(v => (v._1, v._2, v._1.name))
147+
val gitTags = parseVersionsFromRefs(t.repo.allTags).map(v => (v._1, v._2, v._1.name))
148148
val gitBranches = parseVersionsFromRefs(
149149
t.repo.allBranches
150150
.filter(_._1.matches("""\d+\.\d+\.x""")),
151151
).map(v => (v._1, v._2, v._1.name))
152152
val mainVersion = determineMainVersion(t).map(v => (v._1, v._2, "main"))
153153

154154
implicit val lang = t.config.lang
155-
val versions = versionsToTranslations(
155+
val versions = versionsToTranslations(
156156
t.repo,
157157
gitTags ++ gitBranches ++ mainVersion,
158158
defaultTranslation,
@@ -184,8 +184,8 @@ class DocumentationPollingActor(
184184
.sortBy(_._1)
185185
.reverse
186186
.map { version =>
187-
val baseRepo = repo.fileRepoForHash(version._2)
188-
val aggregateVersion = aggregate.byVersion.get(version._1)
187+
val baseRepo = repo.fileRepoForHash(version._2)
188+
val aggregateVersion = aggregate.byVersion.get(version._1)
189189
val (fileRepo, cacheId) =
190190
aggregateVersion.fold(baseRepo -> xorHashes(version._2.name, utils.SiteVersion.hash)) { default =>
191191
new AggregateFileRepository(Seq(baseRepo, default.repo)) ->
@@ -195,7 +195,7 @@ class DocumentationPollingActor(
195195
old.flatMap(_.byVersion.get(version._1)) match {
196196
// The version hasn't changed, don't rescan
197197
case Some(same: TranslationVersion) if same.cacheId == cacheId => same
198-
case _ =>
198+
case _ =>
199199
val playDoc = new PlayDoc(
200200
markdownRepository = fileRepo,
201201
codeRepository = fileRepo,

app/controllers/Application.scala

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,16 @@ class Application @Inject() (
5555

5656
}
5757
.orElse {
58-
if(version.isEmpty ||
58+
if (
59+
version.isEmpty ||
5960
(version.exists(_.startsWith("2.")) && !version.contains(releases.latest2.version)) ||
60-
(version.exists(_.startsWith("3.")) && !version.contains(releases.latest3.version))) {
61+
(version.exists(_.startsWith("3.")) && !version.contains(releases.latest3.version))
62+
) {
6163
Some(
62-
s"""Play framework ${if(version.isEmpty || version.exists(_.startsWith("3."))) releases.latest3.version else releases.latest2.version} is out! Check it out <a href="${routes.Application.download}">here</a>.""",
64+
s"""Play framework ${
65+
if (version.isEmpty || version.exists(_.startsWith("3."))) releases.latest3.version
66+
else releases.latest2.version
67+
} is out! Check it out <a href="${routes.Application.download}">here</a>.""",
6368
)
6469
} else {
6570
None
@@ -76,15 +81,15 @@ class Application @Inject() (
7681

7782
def widget(version: Option[String]) = Action.async { request =>
7883
Future.successful(
79-
Ok(views.html.widget(news(version)))
84+
Ok(views.html.widget(news(version))),
8085
)
8186
}
8287

8388
// This used to be the download/getting-started page. We are keeping
8489
// the URL for SEO purposes only.
8590
def download = Action.async { implicit request =>
8691
Future.successful(
87-
MovedPermanently(routes.Application.gettingStarted.path)
92+
MovedPermanently(routes.Application.gettingStarted.path),
8893
)
8994
}
9095

@@ -106,7 +111,7 @@ class Application @Inject() (
106111
def allreleases(platform: Option[String] = None) = Action.async { implicit request =>
107112
val selectedPlatform = Platform(platform.orElse(request.headers.get("User-Agent")))
108113
Future.successful(
109-
Ok(html.allreleases(releases, selectedPlatform))
114+
Ok(html.allreleases(releases, selectedPlatform)),
110115
)
111116
}
112117

@@ -161,24 +166,24 @@ class Application @Inject() (
161166
page match {
162167
case Some(content) =>
163168
Future.successful(
164-
Ok(template(request)(Html(content))).withHeaders(CACHE_CONTROL -> "max-age=10000")
169+
Ok(template(request)(Html(content))).withHeaders(CACHE_CONTROL -> "max-age=10000"),
165170
)
166171
case None =>
167172
Future.successful(
168-
notFound
173+
notFound,
169174
)
170175
}
171176
}
172177

173178
def getInvolved = Action.async { implicit request =>
174179
Future.successful(
175-
Ok(html.getInvolved())
180+
Ok(html.getInvolved()),
176181
)
177182
}
178183

179184
def sponsors = Action.async { implicit request =>
180185
Future.successful(
181-
Ok(html.sponsors())
186+
Ok(html.sponsors()),
182187
)
183188
}
184189

@@ -197,15 +202,15 @@ class Application @Inject() (
197202
.replace("-released", "")
198203
.replace("-", ".")
199204
Future.successful(
200-
MovedPermanently(s"https://github.com/playframework/playframework/releases/tag/$version")
205+
MovedPermanently(s"https://github.com/playframework/playframework/releases/tag/$version"),
201206
)
202207
} else if (route.endsWith("/")) {
203208
Future.successful(
204-
MovedPermanently("/" + request.path.take(request.path.length - 1).dropWhile(_ == '/'))
209+
MovedPermanently("/" + request.path.take(request.path.length - 1).dropWhile(_ == '/')),
205210
)
206211
} else {
207212
Future.successful(
208-
notFound
213+
notFound,
209214
)
210215
}
211216
}
@@ -244,7 +249,7 @@ class Application @Inject() (
244249
val sections = byVersion.map { case (v, p) =>
245250
val TutorialKeyword = "tutorial" // this MUST be in the project keywords for this to work
246251
val SeedKeyword = "seed"
247-
val tutorials = p
252+
val tutorials = p
248253
.filter(e => e.keywords.contains(TutorialKeyword) && !e.hasParams)
249254
.groupBy(byLanguage)
250255
.view

app/controllers/Blog.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,25 @@ class Blog @Inject() (
3030

3131
def index() = Action.async { implicit request =>
3232
Future.successful(
33-
Ok(html.blog.index(blogName))
33+
Ok(html.blog.index(blogName)),
3434
)
3535
}
3636

3737
def graal() = Action.async { implicit request =>
3838
Future.successful(
39-
Ok(html.blog.graal(blogName, "Running Play on GraalVM"))
39+
Ok(html.blog.graal(blogName, "Running Play on GraalVM")),
4040
)
4141
}
4242

4343
def socketio() = Action.async { implicit request =>
4444
Future.successful(
45-
Ok(html.blog.socketio(blogName, "Play socket.io support"))
45+
Ok(html.blog.socketio(blogName, "Play socket.io support")),
4646
)
4747
}
4848

4949
def ossPledgeLaunch() = Action.async { implicit request =>
5050
Future.successful(
51-
Ok(html.blog.ossPledgeLaunch(blogName, "Celebrating the Launch of the Open Source Pledge"))
51+
Ok(html.blog.ossPledgeLaunch(blogName, "Celebrating the Launch of the Open Source Pledge")),
5252
)
5353
}
5454
}

app/controllers/Modules.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
2525
case Accepts.Json() =>
2626
import Module.modulesWrites
2727
Ok(Json.toJson(moduleDao.findEverything()))
28-
}
28+
},
2929
)
3030
}
3131

3232
def download(name: String, version: String) = Action.async { implicit request =>
3333
modulesLookup.findModule(name, version) match {
3434
case Some(zip) =>
3535
Future.successful(
36-
Ok.sendFile(zip)
36+
Ok.sendFile(zip),
3737
)
3838
case None =>
3939
Future.successful(
40-
PageNotFound
40+
PageNotFound,
4141
)
4242
}
4343
}
@@ -46,11 +46,11 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
4646
modulesLookup.loadModuleDocumentation(name, version, page) match {
4747
case Some(content) =>
4848
Future.successful(
49-
Ok(views.html.modules.documentation(name, content))
49+
Ok(views.html.modules.documentation(name, content)),
5050
)
5151
case None =>
5252
Future.successful(
53-
PageNotFound
53+
PageNotFound,
5454
)
5555
}
5656
}
@@ -59,11 +59,11 @@ class Modules @Inject() (modulesLookup: ModulesLookup, moduleDao: ModuleDao, com
5959
moduleDao.findById(name) match {
6060
case Some((module, releases)) =>
6161
Future.successful(
62-
Ok(views.html.modules.show(module, releases))
62+
Ok(views.html.modules.show(module, releases)),
6363
)
6464
case None =>
6565
Future.successful(
66-
PageNotFound
66+
PageNotFound,
6767
)
6868
}
6969
}

app/controllers/Outreachy.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ class Outreachy @Inject() (components: ControllerComponents)(implicit
1414
reverseRouter: documentation.ReverseRouter,
1515
) extends AbstractController(components) {
1616

17-
//def outreachy = Action(Redirect(routes.Outreachy.round15))
17+
// def outreachy = Action(Redirect(routes.Outreachy.round15))
1818

1919
def round10 = Action.async { implicit req =>
2020
Future.successful(
21-
Ok(views.html.outreachy.round10())
21+
Ok(views.html.outreachy.round10()),
2222
)
2323
}
2424

2525
def round15 = Action.async { implicit req =>
2626
Future.successful(
27-
Ok(views.html.outreachy.round15())
27+
Ok(views.html.outreachy.round15()),
2828
)
2929
}
3030
}

app/controllers/Security.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,23 @@ class Security @Inject() (environment: Environment, val controllerComponents: Co
3737
"Play Framework Security Advisory",
3838
Html(Markdown.toHtml(content, link => (link, link))),
3939
),
40-
).withHeaders(CACHE_CONTROL -> "max-age=10000")
40+
).withHeaders(CACHE_CONTROL -> "max-age=10000"),
4141
)
4242
} finally {
4343
is.close()
4444
}
4545
}
4646
.getOrElse(
4747
Future.successful(
48-
notFound
49-
)
48+
notFound,
49+
),
5050
)
5151
}
5252
}
5353

5454
def index = Action.async { implicit req =>
5555
Future.successful(
56-
Ok(views.html.vulnerabilities()).withHeaders(CACHE_CONTROL -> "max-age=1000")
56+
Ok(views.html.vulnerabilities()).withHeaders(CACHE_CONTROL -> "max-age=1000"),
5757
)
5858
}
5959

0 commit comments

Comments
 (0)