Skip to content

Commit 4829274

Browse files
committed
Revise operators style
1 parent 7fa537e commit 4829274

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

lib.ring

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ class SysInfo {
405405
for path in dmiPaths {
406406
if (fexists(path)) {
407407
fileContent = trim(readFile(path))
408-
if (!isNull(fileContent) and len(fileContent) > 0) {
408+
if (!isNull(fileContent) && len(fileContent) > 0) {
409409
model = substr(fileContent, nl, "")
410410
return model
411411
}
@@ -539,7 +539,7 @@ class SysInfo {
539539

540540
// First get CPU model
541541
for line in lines {
542-
if (substr(line, "model name") and modelName = "") {
542+
if (substr(line, "model name") && modelName = "") {
543543
colonPos = substr(line, ":")
544544
if (colonPos > 0) {
545545
modelName = trim(substr(line, colonPos + 1))
@@ -728,7 +728,7 @@ class SysInfo {
728728
// Initialize shellVersion
729729
shellVersion = "Unknown"
730730
// Skip version check for sh and dash shells since they don't support --version
731-
if !(shell[:name] = "sh" or shell[:name] = "dash") {
731+
if !(shell[:name] = "sh" || shell[:name] = "dash") {
732732
// Execute the shell with the version argument to retrieve the shell version
733733
shellVersion = systemCmd(shellInfo + " --version")
734734
}
@@ -843,7 +843,7 @@ class SysInfo {
843843
// Helper function to calculate uptime based on uptimeInfo and the given params list
844844
func calcUptime(uptimeInfo, params) {
845845
// Set default parameter values if not provided, not a list, or the list is empty
846-
if (!isList(params) or len(params) = 0) {
846+
if (!isList(params) || len(params) = 0) {
847847
params = [:days = 1, :hours = 1, :minutes = 1, :seconds = 1]
848848
}
849849

@@ -855,7 +855,7 @@ class SysInfo {
855855
for tUnit in tUnits {
856856
if (params[tUnit[3]] = 1) {
857857
value = floor(totalSeconds / tUnit[1])
858-
if (value > 0 or len(fUptime) > 0) {
858+
if (value > 0 || len(fUptime) > 0) {
859859
if (len(fUptime) > 0) {
860860
fUptime += ", "
861861
}
@@ -961,7 +961,7 @@ class SysInfo {
961961
diskSize = number(bytesStr) / 1024
962962

963963
// Only add if disk name and size are valid
964-
if (!isNull(currentDisk) and diskSize > 0) {
964+
if (!isNull(currentDisk) && diskSize > 0) {
965965
add(blockDevices, [:name = currentDisk, :size = diskSize])
966966
}
967967

@@ -1027,7 +1027,7 @@ class SysInfo {
10271027
lines = split(output, nl)
10281028

10291029
for line in lines {
1030-
if (!isNull(line) and len(trim(line)) > 0) {
1030+
if (!isNull(line) && len(trim(line)) > 0) {
10311031
// Parse each line of ip addr output
10321032
parts = split(line, " ")
10331033

@@ -1046,7 +1046,7 @@ class SysInfo {
10461046
ipAddress = ipParts[1]
10471047

10481048
// Skip loopback unless it's the only interface
1049-
if (interfaceName = "lo" and len(interfaces) > 0) {
1049+
if (interfaceName = "lo" && len(interfaces) > 0) {
10501050
loop
10511051
}
10521052

@@ -1095,16 +1095,16 @@ class SysInfo {
10951095
if (colonPos > 0) {
10961096
potentialName = left(trimmed_line, colonPos - 1)
10971097
// Ensure potentialName is a valid interface name
1098-
if (len(potentialName) > 0 and !substr(potentialName, " ")) {
1099-
if lower(potentialName) != "status" and lower(potentialName) != "media" and lower(potentialName) != "options" and lower(potentialName) != "ether" and lower(potentialName) != "groups" {
1098+
if (len(potentialName) > 0 && !substr(potentialName, " ")) {
1099+
if (lower(potentialName) != "status" && lower(potentialName) != "media" && lower(potentialName) != "options" && lower(potentialName) != "ether" && lower(potentialName) != "groups") {
11001100
isInterfaceLine = true
11011101
}
11021102
}
11031103
}
11041104
}
11051105

11061106
if (isInterfaceLine) {
1107-
if (!isNull(currentInterface) and !isNull(currentIP)) {
1107+
if (!isNull(currentInterface) && !isNull(currentIP)) {
11081108
add(interfaces, [
11091109
:name = currentInterface,
11101110
:ip = currentIP,
@@ -1116,7 +1116,7 @@ class SysInfo {
11161116
currentInterface = left(trimmed_line, colonPos - 1)
11171117
currentIP = ""
11181118

1119-
elseif (!isNull(currentInterface) and (substr(trimmed_line, "inet ") or substr(trimmed_line, "inet addr:")))
1119+
elseif (!isNull(currentInterface) && (substr(trimmed_line, "inet ") || substr(trimmed_line, "inet addr:")))
11201120
ipLineContent = ""
11211121
if (substr(trimmed_line, "inet addr:")) {
11221122
ipLineContent = trim(substr(trimmed_line, substr(trimmed_line, "inet addr:") + len("inet addr:")))
@@ -1133,15 +1133,15 @@ class SysInfo {
11331133
tempIP = ipLineContent
11341134
}
11351135

1136-
if (!substr(tempIP, ":") and currentIP = "") {
1136+
if (!substr(tempIP, ":") && currentIP = "") {
11371137
currentIP = tempIP
11381138
}
11391139
}
11401140
}
11411141
}
11421142

11431143
// Add the last interface found, if it has an IP
1144-
if (!isNull(currentInterface) and !isNull(currentIP)) {
1144+
if (!isNull(currentInterface) && !isNull(currentIP)) {
11451145
add(interfaces, [
11461146
:name = currentInterface,
11471147
:ip = currentIP,

0 commit comments

Comments
 (0)