Skip to content

Commit ae81b36

Browse files
committed
Add scalafmt
1 parent 3cf98ff commit ae81b36

25 files changed

+106
-67
lines changed

.scalafmt.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version = "3.7.14"
22
maxColumn = 80
3-
docstrings.oneline = keep
3+
docstrings.oneline = unfold
44
docstrings.removeEmpty = false
55
docstrings.wrap = yes
66
docstrings.wrapMaxColumn = null

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ cat log.txt | node ./json-log-viewer/js/target/scala-3.3.1/json-log-viewer-opt/m
5151
Integrate json-log-viewer with k9s to view formatted JSON logs directly within the k9s interface.
5252

5353
Add the following to your k9s plugin file
54-
(usually located at ~/.k9s/pluginы.yaml or, on macOS, check the plugin path with `k9s info`):
54+
(usually located at ~/.k9s/plugins.yaml or, on macOS, check the plugin path with `k9s info`):
5555

5656
```yaml
5757
plugins:

frontend-laminar/src/main/scala/Ansi2HtmlWithClasses.scala

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
21
import fansi.ErrorMode
32
import fansi.Str
43

54
import scala.scalajs.js.annotation.JSExport
65

7-
/**
8-
* https://github.com/com-lihaoyi/fansi/issues/62
9-
*/
6+
/** https://github.com/com-lihaoyi/fansi/issues/62
7+
*/
108
object Ansi2HtmlWithClasses extends Function1[String, String]:
119
private def transition(from: fansi.Attr, to: fansi.Attr) =
1210
import fansi.*
@@ -16,7 +14,7 @@ object Ansi2HtmlWithClasses extends Function1[String, String]:
1614
case (Bold.Off, Bold.On) => "<b>"
1715
case (Bold.On, Bold.Off) => "</b>"
1816
case (col1, col2) if color.isDefinedAt(col2) =>
19-
val closing = if color.isDefinedAt(col1) then "</span>" else ""
17+
val closing = if color.isDefinedAt(col1) then "</span>" else ""
2018
val nextColor = color(col2)
2119
s"$closing<span class='text-break ansi-$nextColor'>"
2220
case (col1, fansi.Color.Reset) if color.isDefinedAt(col1) =>
@@ -46,7 +44,7 @@ object Ansi2HtmlWithClasses extends Function1[String, String]:
4644

4745
@JSExport("ansi_2_html")
4846
def apply(s: String): String =
49-
val colored = fansi.Str(s, ErrorMode.Strip)
47+
val colored = fansi.Str(s, ErrorMode.Strip)
5048
var current: Str.State = 0L
5149

5250
val categories = fansi.Attr.categories
@@ -84,4 +82,4 @@ object Ansi2HtmlWithClasses extends Function1[String, String]:
8482

8583
sb.result()
8684
end apply
87-
end Ansi2HtmlWithClasses
85+
end Ansi2HtmlWithClasses
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import com.raquo.laminar.api.L.{*, given}
32
import com.raquo.laminar.api.L
43
object EditElement {
@@ -8,7 +7,8 @@ object EditElement {
87
textArea(
98
minHeight := "400px",
109
cls := "col-12",
11-
typ := "text", mods
10+
typ := "text",
11+
mods
1212
)
1313
)
1414
}

frontend-laminar/src/main/scala/Router0.scala

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,41 @@ object Router0 {
1616
given codec: JsonValueCodec[Page] = JsonCodecMaker.make
1717

1818
private val routes = List(
19-
Route.static(LivePage, root / endOfSegments, dom.window.location.pathname + "#"),
20-
Route.static(EditPage, root / "edit" / endOfSegments, dom.window.location.pathname + "#"),
21-
Route.static(ViewPage, root / "view" / endOfSegments, dom.window.location.pathname + "#"),
22-
Route.static(HelpPage, root / "help" / endOfSegments, dom.window.location.pathname + "#")
19+
Route.static(
20+
LivePage,
21+
root / endOfSegments,
22+
dom.window.location.pathname + "#"
23+
),
24+
Route.static(
25+
EditPage,
26+
root / "edit" / endOfSegments,
27+
dom.window.location.pathname + "#"
28+
),
29+
Route.static(
30+
ViewPage,
31+
root / "view" / endOfSegments,
32+
dom.window.location.pathname + "#"
33+
),
34+
Route.static(
35+
HelpPage,
36+
root / "help" / endOfSegments,
37+
dom.window.location.pathname + "#"
38+
)
2339
)
2440

2541
val router = new Router[Page](
2642
routes = routes,
2743
getPageTitle = _.title, // displayed in the browser tab next to favicon
28-
serializePage = page => writeToString(page), // serialize page data for storage in History API log
29-
deserializePage = pageStr => readFromString(pageStr) // deserialize the above
44+
serializePage = page =>
45+
writeToString(
46+
page
47+
), // serialize page data for storage in History API log
48+
deserializePage = pageStr =>
49+
readFromString(pageStr) // deserialize the above
3050
)(
31-
popStateEvents = windowEvents(_.onPopState), // this is how Waypoint avoids an explicit dependency on Laminar
51+
popStateEvents = windowEvents(
52+
_.onPopState
53+
), // this is how Waypoint avoids an explicit dependency on Laminar
3254
owner = unsafeWindowOwner // this router will live as long as the window
3355
)
3456

@@ -47,9 +69,10 @@ object Router0 {
4769
// Otherwise:
4870
// - Perform regular pushState transition
4971
(onClick
50-
.filter(ev => !(isLinkElement && (ev.ctrlKey || ev.metaKey || ev.shiftKey || ev.altKey)))
72+
.filter(ev =>
73+
!(isLinkElement && (ev.ctrlKey || ev.metaKey || ev.shiftKey || ev.altKey))
74+
)
5175
.preventDefault
52-
--> (_ => router.pushState(page))
53-
).bind(el)
76+
--> (_ => router.pushState(page))).bind(el)
5477
}
55-
}
78+
}

frontend-laminar/src/main/scala/ViewElement.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,11 @@ object ViewElement {
3232
val jsonPrefixPostfix = JsonPrefixPostfix(JsonDetector())
3333
val logLineParser = c.formatIn match
3434
case Some(FormatIn.Logfmt) => LogfmtLogLineParser(c)
35-
case Some(FormatIn.Json) => JsonLogLineParser(c, jsonPrefixPostfix)
36-
case other => throw new IllegalStateException(s"Unsupported format-in value: $other")
35+
case Some(FormatIn.Json) => JsonLogLineParser(c, jsonPrefixPostfix)
36+
case other =>
37+
throw new IllegalStateException(
38+
s"Unsupported format-in value: $other"
39+
)
3740

3841
fs2.Stream
3942
.emits(string.split("\n"))

json-log-viewer/jvm/src/main/scala/ru/d10xa/jsonlogviewer/decline/ConfigInitImpl.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import java.io.File
1111
class ConfigInitImpl extends ConfigInit {
1212

1313
override def initConfig(c: Config): IO[Config] = {
14-
def findConfigFile(baseName: String, extensions: List[String]): Option[String] = {
14+
def findConfigFile(
15+
baseName: String,
16+
extensions: List[String]
17+
): Option[String] = {
1518
extensions.collectFirst {
1619
case ext if new File(s"$baseName.$ext").exists() =>
1720
s"$baseName.$ext"
@@ -33,7 +36,9 @@ class ConfigInitImpl extends ConfigInit {
3336
)
3437
}
3538
case Some(file) =>
36-
IO.raiseError(new IllegalArgumentException(s"Configuration file not found: $file"))
39+
IO.raiseError(
40+
new IllegalArgumentException(s"Configuration file not found: $file")
41+
)
3742
case None =>
3843
None.pure[IO]
3944
}

json-log-viewer/shared/src/main/scala/ru/d10xa/jsonlogviewer/ConfigYamlReader.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ import scala.io.Source
1010
object ConfigYamlReader {
1111

1212
def readFile(filePath: String): IO[String] =
13-
IO.blocking(Source.fromFile(filePath)).bracket { source =>
14-
IO(source.mkString)
15-
} { source =>
16-
IO(source.close())
17-
}
13+
IO.blocking(Source.fromFile(filePath))
14+
.bracket { source =>
15+
IO(source.mkString)
16+
} { source =>
17+
IO(source.close())
18+
}
1819

1920
def fromYamlFile(filePath: String): IO[ValidatedNel[String, ConfigYaml]] =
2021
readFile(filePath).map(ConfigYamlLoader.parseYamlFile)
21-
}
22+
}

json-log-viewer/shared/src/main/scala/ru/d10xa/jsonlogviewer/JsonDetector.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ class JsonDetector {
2424
res match
2525
case (-1, _) => None
2626
case (_, -1) => None
27-
case (i, j) => Some(i, j)
27+
case (i, j) => Some(i, j)
2828
}

json-log-viewer/shared/src/main/scala/ru/d10xa/jsonlogviewer/JsonLogLineParser.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import cats.syntax.all.*
88
import HardcodedFieldNames.*
99
import ru.d10xa.jsonlogviewer.decline.Config
1010

11-
class JsonLogLineParser(config: Config, jsonPrefixPostfix: JsonPrefixPostfix) extends LogLineParser {
11+
class JsonLogLineParser(config: Config, jsonPrefixPostfix: JsonPrefixPostfix)
12+
extends LogLineParser {
1213
given Decoder[ParsedLine] = (c: HCursor) =>
1314
val timestampFieldName = config.timestamp.fieldName
1415

0 commit comments

Comments
 (0)