Skip to content

Commit 1d81e21

Browse files
committed
Refactoring. Change def to val for immutable objects
1 parent 1f3a80e commit 1d81e21

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

src/main/scala/gitbucket/monitoring/services/MachineResources.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import gitbucket.monitoring.utils._
88
trait MachineResources {
99
private val fileStore = Files.getFileStore(Paths.get("."))
1010

11-
def cpuCore = Runtime.getRuntime().availableProcessors()
11+
val cpuCore = Runtime.getRuntime().availableProcessors()
1212

1313
def getCpu: Either[String, Cpu] = {
1414
try {

src/main/scala/gitbucket/monitoring/services/SystemInformation.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import scala.sys.process._
77
import gitbucket.monitoring.utils._
88

99
trait SystemInformation {
10-
def timeZone = ZoneId.systemDefault()
10+
val timeZone = ZoneId.systemDefault()
1111
def nowTime = LocalDateTime.now()
1212
def zoneOffset = timeZone.getRules().getOffset(nowTime)
1313
def dayOfWeek = nowTime.getDayOfWeek()
1414

15-
def onDocker: Boolean = {
15+
val onDocker: Boolean = {
1616
try {
1717
Files.exists(Paths.get("/.dockerenv"))
1818
} catch {

src/main/scala/gitbucket/monitoring/services/operatingsystem/OperatingSystem.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ object OperatingSystem {
1212

1313
val osArch = System.getProperty("os.arch")
1414
val osName = System.getProperty("os.name")
15-
16-
def osType: OSType = {
15+
val osType: OSType = {
1716
if (osName.toLowerCase.contains("linux")) {
1817
Linux
1918
} else if (osName.toLowerCase.contains("windows")) {
@@ -25,7 +24,7 @@ object OperatingSystem {
2524
}
2625
}
2726

28-
def osVersion:String = osType match {
27+
val osVersion:String = osType match {
2928
case Windows => {
3029
(Process("powershell -Command Get-WmiObject Win32_OperatingSystem | %{ $_.Version }") !!).toString
3130
}
@@ -34,7 +33,7 @@ object OperatingSystem {
3433
}
3534
}
3635

37-
def distribution: String = osType match {
36+
val distribution: String = osType match {
3837
case Linux => {
3938
try {
4039
val result = Process("cat /etc/issue") !!
@@ -49,7 +48,7 @@ object OperatingSystem {
4948
}
5049
}
5150

52-
def getInstance = osType match {
51+
val getInstance = osType match {
5352
case OperatingSystem.Linux => new Linux
5453
case OperatingSystem.Mac => new Mac
5554
case OperatingSystem.Windows => new Windows

0 commit comments

Comments
 (0)